Example usage for com.vaadin.ui GridLayout GridLayout

List of usage examples for com.vaadin.ui GridLayout GridLayout

Introduction

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

Prototype

public GridLayout(int columns, int rows) 

Source Link

Document

Constructor for a grid of given size (number of columns and rows).

Usage

From source file:com.esofthead.mycollab.mobile.ui.grid.GridFormLayoutHelper.java

License:Open Source License

public GridFormLayoutHelper(final int columns, final int rows, final String fieldControlWidth,
        final String defaultCaptionWidth, final Alignment captionAlignment) {
    this.fieldControlWidth = fieldControlWidth;
    this.defaultCaptionWidth = defaultCaptionWidth;
    this.captionAlignment = captionAlignment;

    this.layout = new GridLayout(2 * columns, rows);
    this.layout.setMargin(false);
    this.layout.setSpacing(false);
    this.layout.setRowExpandRatio(0, 0);
}

From source file:com.esofthead.mycollab.mobile.ui.GridFormLayoutHelper.java

License:Open Source License

public GridFormLayoutHelper(final int columns, final int rows, final String fieldControlWidth,
        final String defaultCaptionWidth, final Alignment captionAlignment) {
    this.fieldControlWidth = fieldControlWidth;
    this.defaultCaptionWidth = defaultCaptionWidth;
    this.captionAlignment = captionAlignment;

    this.layout = new GridLayout(2 * columns, rows);
    this.layout.setMargin(new MarginInfo(true, false, false, false));
    this.layout.setSpacing(false);

    this.layout.setRowExpandRatio(0, 0);
}

From source file:com.esofthead.mycollab.module.crm.ui.components.PeopleInfoComp.java

License:Open Source License

public void displayEntryPeople(ValuedBean bean) {
    this.removeAllComponents();
    this.withMargin(new MarginInfo(true, false, true, true));

    Label peopleInfoHeader = new Label(
            FontAwesome.USER.getHtml() + " " + AppContext.getMessage(CrmCommonI18nEnum.SUB_INFO_PEOPLE),
            ContentMode.HTML);/*from   w w  w.  j a v a  2  s  .c om*/
    peopleInfoHeader.setStyleName("info-hdr");
    this.addComponent(peopleInfoHeader);

    GridLayout layout = new GridLayout(2, 2);
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setMargin(new MarginInfo(false, false, false, true));
    try {
        Label createdLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_CREATED_PEOPLE));
        createdLbl.setSizeUndefined();
        layout.addComponent(createdLbl, 0, 0);

        String createdUserName = (String) PropertyUtils.getProperty(bean, "createduser");
        String createdUserAvatarId = (String) PropertyUtils.getProperty(bean, "createdUserAvatarId");
        String createdUserDisplayName = (String) PropertyUtils.getProperty(bean, "createdUserFullName");

        UserLink createdUserLink = new UserLink(createdUserName, createdUserAvatarId, createdUserDisplayName);
        layout.addComponent(createdUserLink, 1, 0);
        layout.setColumnExpandRatio(1, 1.0f);

        Label assigneeLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_ASSIGN_PEOPLE));
        assigneeLbl.setSizeUndefined();
        layout.addComponent(assigneeLbl, 0, 1);
        String assignUserName = (String) PropertyUtils.getProperty(bean, "assignuser");
        String assignUserAvatarId = (String) PropertyUtils.getProperty(bean, "assignUserAvatarId");
        String assignUserDisplayName = (String) PropertyUtils.getProperty(bean, "assignUserFullName");

        UserLink assignUserLink = new UserLink(assignUserName, assignUserAvatarId, assignUserDisplayName);
        layout.addComponent(assignUserLink, 1, 1);
    } catch (Exception e) {
        LOG.error("Can not build user link {} ", BeanUtility.printBeanObj(bean));
    }

    this.addComponent(layout);

}

From source file:com.esofthead.mycollab.module.crm.view.account.AccountSimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 3);
    layoutSearchPane.setSpacing(true);//from  w  ww. j  a  v a2s . co m
    final ValueComboBox group = new ValueComboBox(false, "Name", "Email", "Website", "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("Website")) {
                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.setDescription("Search");

    searchBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            searchCriteria = new AccountSearchCriteria();
            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.setAccountname(new StringSearchField(SearchField.AND, strSearch));
                        } else if (searchType.equals("Email")) {
                            searchCriteria.setAnyMail(new StringSearchField(SearchField.AND, strSearch));
                        } else if (searchType.equals("Website")) {
                            searchCriteria.setWebsite(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<>(SearchField.AND, new String[] { user }));
                    }
                }
            }

            AccountSimpleSearchPanel.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.campaign.CampaignSimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 2);
    layoutSearchPane.setSpacing(true);//from  w  w w  . j av  a  2s  .  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.CaseSimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 3);
    layoutSearchPane.setSpacing(true);/*ww  w.j  a va2 s.  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.ContactSimpleSearchPanel.java

License:Open Source License

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

    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);
}

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

License:Open Source License

public CrmToolbar() {
    super();//from  w w  w. j  a v  a  2s .  co m
    this.setStyleName("crm-toolbar");
    this.setWidth("100%");
    this.setMargin(new MarginInfo(false, true, false, true));
    final NavigatorItemListener listener = new NavigatorItemListener();
    final Button homeBtn = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_DASHBOARD_HEADER),
            listener);
    homeBtn.setStyleName("link");
    addComponent(homeBtn);

    final Button accountList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_ACCOUNTS_HEADER),
            listener);
    accountList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_ACCOUNT));
    accountList.setStyleName("link");
    addComponent(accountList);

    final Button contactList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CONTACTS_HEADER),
            listener);
    contactList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CONTACT));
    contactList.setStyleName("link");
    addComponent(contactList);

    final Button campaignList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CAMPAIGNS_HEADER),
            listener);
    campaignList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CAMPAIGN));
    campaignList.setStyleName("link");
    addComponent(campaignList);

    final Button leadList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_LEADS_HEADER), listener);
    leadList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_LEAD));
    leadList.setStyleName("link");
    addComponent(leadList);

    final Button opportunityList = new Button(
            AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_OPPORTUNTIES_HEADER), listener);
    opportunityList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_OPPORTUNITY));
    opportunityList.setStyleName("link");
    addComponent(opportunityList);

    final Button caseList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CASES_HEADER), listener);
    caseList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CASE));
    caseList.setStyleName("link");
    addComponent(caseList);

    final Button activitiesList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_ACTIVITIES_HEADER),
            listener);
    final boolean isActivityEnable = AppContext.canRead(RolePermissionCollections.CRM_MEETING)
            || AppContext.canRead(RolePermissionCollections.CRM_TASK)
            || AppContext.canRead(RolePermissionCollections.CRM_CALL);
    activitiesList.setEnabled(isActivityEnable);
    activitiesList.setStyleName("link");
    addComponent(activitiesList);

    addStyleName("h-sidebar-menu");

    final Button fileBtn = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_DOCUMENT_HEADER),
            listener);
    fileBtn.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_DOCUMENT));
    fileBtn.setStyleName("link");
    addComponent(fileBtn);

    final Button notificationBtn = new Button(
            AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CRMNOTIFICATION_HEADER), listener);
    notificationBtn.setStyleName("link");
    addComponent(notificationBtn);

    addBtn = new PopupButton(AppContext.getMessage(CrmCommonI18nEnum.BUTTON_CREATE));
    final GridLayout addBtnLayout = new GridLayout(3, 2);
    addBtnLayout.setMargin(true);
    addBtnLayout.setWidth("370px");
    addBtnLayout.setSpacing(true);

    final ButtonLink newAccountBtn = new ButtonLink(AppContext.getMessage(AccountI18nEnum.BUTTON_NEW_ACCOUNT),
            listener, false);
    newAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_ACCOUNT));
    newAccountBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.ACCOUNT));
    addBtnLayout.addComponent(newAccountBtn);

    final ButtonLink newContactBtn = new ButtonLink(AppContext.getMessage(ContactI18nEnum.BUTTON_NEW_CONTACT),
            listener, false);
    newContactBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    newContactBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT));
    addBtnLayout.addComponent(newContactBtn);

    final ButtonLink newCampaignBtn = new ButtonLink(
            AppContext.getMessage(CampaignI18nEnum.BUTTON_NEW_CAMPAIGN), listener, false);
    newCampaignBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CAMPAIGN));
    newCampaignBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CAMPAIGN));
    addBtnLayout.addComponent(newCampaignBtn);

    final ButtonLink newOpportunityBtn = new ButtonLink(
            AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY), listener, false);
    newOpportunityBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY));
    newOpportunityBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY));
    addBtnLayout.addComponent(newOpportunityBtn);

    final ButtonLink newLeadBtn = new ButtonLink(AppContext.getMessage(LeadI18nEnum.BUTTON_NEW_LEAD), listener,
            false);
    newLeadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_LEAD));
    newLeadBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.LEAD));
    addBtnLayout.addComponent(newLeadBtn);

    final ButtonLink newCaseBtn = new ButtonLink(AppContext.getMessage(CaseI18nEnum.BUTTON_NEW_CASE), listener,
            false);
    newCaseBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CASE));
    newCaseBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CASE));
    addBtnLayout.addComponent(newCaseBtn);

    final ButtonLink newTaskBtn = new ButtonLink(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK), listener,
            false);
    newTaskBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_TASK));
    newTaskBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.TASK));
    addBtnLayout.addComponent(newTaskBtn);

    final ButtonLink newCallBtn = new ButtonLink(AppContext.getMessage(CallI18nEnum.BUTTON_NEW_CALL), listener,
            false);
    newCallBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CALL));
    newCallBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CALL));
    addBtnLayout.addComponent(newCallBtn);

    final ButtonLink newMeetingBtn = new ButtonLink(AppContext.getMessage(MeetingI18nEnum.BUTTON_NEW_MEETING),
            listener, false);
    newMeetingBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_MEETING));
    newMeetingBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.MEETING));
    addBtnLayout.addComponent(newMeetingBtn);

    addBtn.setContent(addBtnLayout);
    addBtn.setStyleName("link");
    addBtn.addStyleName("quickadd-btn");
    addComponent(addBtn);

    setExpandRatio(addBtn, 1.0f);
    setComponentAlignment(addBtn, Alignment.MIDDLE_RIGHT);
}

From source file:com.esofthead.mycollab.module.crm.view.lead.LeadSimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 3);
    layoutSearchPane.setSpacing(true);//from   w w w. j a  v  a 2  s  .c o  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() {
        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();
            }
        }
    });

    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() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            searchCriteria = new LeadSearchCriteria();
            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.setLeadName(new StringSearchField(SearchField.AND, strSearch));
                        }
                    }
                }

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

            LeadSimpleSearchPanel.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.opportunity.OpportunitySimpleSearchPanel.java

License:Open Source License

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

    final ValueComboBox 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();
            }
        }
    });

    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 OpportunitySearchCriteria();
            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
                                    .setOpportunityName(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 }));
                    }
                }
            }

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