Example usage for com.vaadin.ui CssLayout removeComponent

List of usage examples for com.vaadin.ui CssLayout removeComponent

Introduction

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

Prototype

@Override
public void removeComponent(Component c) 

Source Link

Document

Removes the component from this container.

Usage

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

License:Open Source License

private ComponentContainer createBody() {
    final CssLayout layout = new CssLayout();
    layout.setSizeFull();//from w w w.  ja  v a2  s  . c  o m

    Label shortDescription = new Label(
            "<p>&nbsp;&nbsp;&nbsp;By clicking the \"Convert\" button, the following tasks will be done:</p>",
            ContentMode.HTML);
    layout.addComponent(shortDescription);

    VerticalLayout infoLayout = new VerticalLayout();
    infoLayout.setMargin(new MarginInfo(false, true, true, true));
    infoLayout.setSpacing(true);

    String createAccountTxt = "Create Account: <span class='" + UIConstants.TEXT_BLUE + "'>"
            + lead.getAccountname() + "</span>";
    Label createAccountLbl = new Label(createAccountTxt, ContentMode.HTML);
    createAccountLbl.addStyleName(UIConstants.LABEL_CHECKED);
    infoLayout.addComponent(createAccountLbl);

    String createContactTxt = "Create Contact: <span class='" + UIConstants.TEXT_BLUE + "'>"
            + lead.getLastname() + (lead.getFirstname() != null ? " " + lead.getFirstname() : "") + "</span>";
    Label createContactLbl = new Label(createContactTxt, ContentMode.HTML);
    createContactLbl.addStyleName(UIConstants.LABEL_CHECKED);
    infoLayout.addComponent(createContactLbl);

    final CheckBox isCreateOpportunityChk = new CheckBox("Create a new opportunity for this account");
    isCreateOpportunityChk.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            Boolean isSelected = isCreateOpportunityChk.getValue();
            if (isSelected) {
                opportunityForm = new LeadOpportunityForm();
                Opportunity opportunity = new Opportunity();

                // this is a trick to pass validation
                opportunity.setAccountid(0);
                opportunityForm.setBean(opportunity);
                layout.addComponent(opportunityForm);
            } else {
                layout.removeComponent(opportunityForm);
            }

        }
    });

    infoLayout.addComponent(isCreateOpportunityChk);

    layout.addComponent(infoLayout);
    return layout;
}

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

License:Open Source License

private ComponentContainer createBody() {
    final CssLayout layout = new CssLayout();
    layout.setSizeFull();//from w  ww  .j  av a2  s . c om

    Label shortDescription = ELabel.html(
            "<p>&nbsp;&nbsp;&nbsp;By clicking the \"Convert\" button, the following tasks will be done:</p>");
    layout.addComponent(shortDescription);

    MVerticalLayout infoLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, true));

    String createAccountTxt = FontAwesome.CHECK.getHtml() + " Create Account: " + lead.getAccountname();
    Label createAccountLbl = new Label(createAccountTxt, ContentMode.HTML);
    infoLayout.addComponent(createAccountLbl);

    String createContactTxt = FontAwesome.CHECK.getHtml() + " Create Contact: " + lead.getLastname()
            + (lead.getFirstname() != null ? " " + lead.getFirstname() : "");
    Label createContactLbl = new Label(createContactTxt, ContentMode.HTML);
    infoLayout.addComponent(createContactLbl);

    final CheckBox isCreateOpportunityChk = new CheckBox("Create a new opportunity for this account");
    isCreateOpportunityChk.addValueChangeListener(valueChangeEvent -> {
        Boolean isSelected = isCreateOpportunityChk.getValue();
        if (isSelected) {
            opportunityForm = new LeadOpportunityForm();
            Opportunity opportunity = new Opportunity();

            // this is a trick to pass validation
            opportunity.setAccountid(0);
            opportunityForm.setBean(opportunity);
            layout.addComponent(opportunityForm);
        } else {
            layout.removeComponent(opportunityForm);
        }
    });

    infoLayout.addComponent(isCreateOpportunityChk);
    layout.addComponent(infoLayout);
    return layout;
}