Example usage for com.vaadin.ui Button click

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

Introduction

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

Prototype

public void click() 

Source Link

Document

Simulates a button click, notifying all server-side listeners.

Usage

From source file:at.peppol.webgui.app.components.PartyDetailForm.java

License:Mozilla Public License

private void initElements() {

    setCaption(party + " Party");
    //setStyleName("light");

    final VerticalLayout outerLayout = new VerticalLayout();
    outerLayout.setSpacing(true);//from  w  w w  . ja v  a2s  . c om
    outerLayout.setMargin(true);

    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);
    hiddenContent.setMargin(true);

    PropertysetItem partyItemSet = new PropertysetItem();

    PartyIdentificationType supplierPartyID;
    if (partyBean.getPartyIdentification().size() == 0) {
        supplierPartyID = new PartyIdentificationType();
        supplierPartyID.setID(new IDType());
        partyBean.getPartyIdentification().add(supplierPartyID);
    } else {
        supplierPartyID = partyBean.getPartyIdentification().get(0);
    }

    partyItemSet.addItemProperty("Party ID", new NestedMethodProperty(supplierPartyID, "ID.value"));

    EndpointIDType endPointID;
    if (partyBean.getEndpointID() == null) {
        endPointID = new EndpointIDType();
        partyBean.setEndpointID(endPointID);
    } else {
        endPointID = partyBean.getEndpointID();
    }
    partyItemSet.addItemProperty("Endpoint ID", new NestedMethodProperty(endPointID, "SchemeAgencyID"));

    PartyNameType partyName;
    if (partyBean.getPartyName().size() == 0) {
        partyName = new PartyNameType();
        partyName.setName(new NameType());
        partyBean.getPartyName().add(partyName);
    } else {
        partyName = partyBean.getPartyName().get(0);
    }
    partyItemSet.addItemProperty("Party Name", new NestedMethodProperty(partyName, "name.value"));

    /*        partyItemSet.addItemProperty("Agency Name", 
        new NestedMethodProperty(supplierPartyID, "ID.SchemeAgencyID") );
    */
    /*
    final AddressType partyrAddress = new AddressType();
            
    partyBean.setPostalAddress(partyrAddress);
    partyrAddress.setStreetName(new StreetNameType());
    partyrAddress.setCityName(new CityNameType());
    partyrAddress.setPostalZone(new PostalZoneType());
    partyrAddress.setCountry(new CountryType());
            
    partyrAddress.getCountry().setIdentificationCode(new IdentificationCodeType());
            
    partyItemSet.addItemProperty("Street Name",
                    new NestedMethodProperty(partyrAddress, "streetName.value"));
    partyItemSet.addItemProperty("City",
                    new NestedMethodProperty(partyrAddress, "cityName.value"));
    partyItemSet.addItemProperty("Postal Zone",
                    new NestedMethodProperty(partyrAddress, "postalZone.value"));
    partyItemSet.addItemProperty("Country",
                    new NestedMethodProperty(partyrAddress, "country.identificationCode.value"));
    */
    AddressDetailForm partyAddressForm;
    AddressType address;
    if (partyBean.getPostalAddress() == null) {
        address = new AddressType();
    } else {
        address = partyBean.getPostalAddress();
    }
    partyAddressForm = new AddressDetailForm(party, address);
    partyBean.setPostalAddress(address);

    PartyTaxSchemeType taxScheme;
    if (partyBean.getPartyTaxScheme().size() == 0) {
        taxScheme = new PartyTaxSchemeType();
        taxScheme.setCompanyID(new CompanyIDType());

        //partyItemSet.addItemProperty(taxSchemeCompanyID,
        //        new NestedMethodProperty(taxScheme.getCompanyID(),"value"));

        // TODO: Hardcoded ShemeID etc for TaxScheme. Should be from a codelist?
        taxScheme.setTaxScheme(new TaxSchemeType());
        taxScheme.getTaxScheme().setID(new IDType());
        taxScheme.getTaxScheme().getID().setValue("VAT");
        taxScheme.getTaxScheme().getID().setSchemeID("UN/ECE 5153");
        taxScheme.getTaxScheme().getID().setSchemeAgencyID("6");

        partyBean.getPartyTaxScheme().add(taxScheme);
    } else {
        taxScheme = partyBean.getPartyTaxScheme().get(0);
    }

    partyItemSet.addItemProperty(taxSchemeCompanyID,
            new NestedMethodProperty(taxScheme.getCompanyID(), "value"));

    partyItemSet.addItemProperty(taxSchemeID,
            new NestedMethodProperty(taxScheme.getTaxScheme().getID(), "value"));

    final Form partyForm = new Form();
    partyForm.setFormFieldFactory(new PartyFieldFactory());
    partyForm.setItemDataSource(partyItemSet);
    partyForm.setImmediate(true);

    final Button addLegalEntityBtn = new Button("Add Legal Entity");
    final Button removeLegalEntityBtn = new Button("Remove Legal Entity");
    //removeLegalEntityBtn.setVisible(false);

    addLegalEntityBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            //add the legal entity component
            Panel panel = createLegalEntityPanel(removeLegalEntityBtn);
            outerLayout.addComponent(panel);
            panel.setWidth("90%");
            addLegalEntityBtn.setVisible(false);
            //removeLegalEntityBtn.setVisible(true);
            //outerLayout.replaceComponent(removeLegalEntityBtn, panel);
        }
    });

    removeLegalEntityBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            //remove the legal entity component
            for (int i = 0; i < outerLayout.getComponentCount(); i++) {
                Component c = outerLayout.getComponent(i);
                if (c instanceof Panel) {
                    if (c.getCaption().equals("Legal Entity")) {
                        outerLayout.removeComponent(c);
                        if (partyBean.getPartyLegalEntity().size() > 0) {
                            partyBean.getPartyLegalEntity().clear();
                            ValidatorsList.removeListeners(Utils.getFieldListeners(legalEntityForm));
                        }
                    }
                }
            }
            //removeLegalEntityBtn.setVisible(false);
            addLegalEntityBtn.setVisible(true);
        }
    });

    outerLayout.addComponent(partyForm);
    partyForm.setWidth("90%");
    outerLayout.addComponent(partyAddressForm);
    partyAddressForm.setWidth("90%");
    outerLayout.addComponent(addLegalEntityBtn);
    if (partyBean.getPartyLegalEntity().size() > 0)
        addLegalEntityBtn.click();
    //outerLayout.addComponent(removeLegalEntityBtn);
    //outerLayout.addComponent(createLegalEntityPanel());

    setContent(outerLayout);
}

From source file:at.peppol.webgui.app.components.TabInvoiceHeader.java

License:Mozilla Public License

private void initElements() {
    additionalDocRefList = parent.getInvoice().getAdditionalDocumentReference();
    setWidth("100%");
    setHeight("100%");
    //final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    //outerLayout.setMargin(true);
    //outerLayout.setSpacing(true);

    //grid that contains "Details", "Contract", "Order"
    final GridLayout topGridLayout = new GridLayout(2, 2);
    //topGridLayout.setSizeFull();
    topGridLayout.setMargin(true);//w  ww.  j  a  v  a2 s .c  o  m
    topGridLayout.setSpacing(true);

    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);
    hiddenContent.setMargin(true);

    final Panel outerPanel = new Panel("Invoice Header");
    //outerPanel.addComponent(grid);
    outerPanel.setScrollable(true);
    outerPanel.setContent(outerLayout);
    //outerLayout.addComponent(outerPanel);

    VerticalLayout tabLayout = new VerticalLayout();
    tabLayout.addComponent(outerPanel);

    outerLayout.addComponent(topGridLayout);

    final Panel invoiceDetailsPanel = new Panel("Invoice Header Details");
    invoiceDetailsPanel.setStyleName("light");
    invoiceDetailsPanel.setWidth("50%");
    //invoiceDetailsPanel.setSizeFull();
    invoiceDetailsPanel.addComponent(createInvoiceTopForm());
    topGridLayout.addComponent(invoiceDetailsPanel, 0, 0);

    final Panel orderReferencePanel = new Panel("Referencing Order");
    orderReferencePanel.setStyleName("light");
    orderReferencePanel.setWidth("50%");
    //orderReferencePanel.setSizeFull();
    orderReferencePanel.addComponent(createInvoiceOrderReferenceForm());
    topGridLayout.addComponent(orderReferencePanel, 0, 1);

    final VerticalLayout tableVerticalLayout = new VerticalLayout();
    //tableVerticalLayout.setSpacing (true);
    tableVerticalLayout.setMargin(true);
    outerLayout.addComponent(tableVerticalLayout);

    table = new InvoiceAdditionalDocRefTable(parent.getInvoice().getAdditionalDocumentReference());
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setSizeFull();
    //table.setWidth("300px");
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    Panel tablePanel = new Panel("Relevant Documents");
    tablePanel.setStyleName("light");
    tablePanel.setWidth("60%");
    tableVerticalLayout.addComponent(tablePanel);

    GridLayout h = new GridLayout(2, 2);
    h.setMargin(true);
    h.setSpacing(true);
    tablePanel.setContent(h);
    h.addComponent(table, 0, 0);
    h.setColumnExpandRatio(0, 3);
    h.setColumnExpandRatio(1, 1);
    h.setSizeFull();

    Button addButton = new Button("Add new");
    Button editButton = new Button("Edit selected");
    Button deleteButton = new Button("Delete selected");

    VerticalLayout buttonsContainer = new VerticalLayout();
    buttonsContainer.setSpacing(true);
    buttonsContainer.addComponent(addButton);
    buttonsContainer.addComponent(editButton);
    buttonsContainer.addComponent(deleteButton);

    InvoiceAdditionalDocRefTableEditor editor = new InvoiceAdditionalDocRefTableEditor(editMode);
    Label label = new Label("<h3>Adding new relevant document</h3>", Label.CONTENT_XHTML);
    addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table,
            additionalDocRefList, label));
    label = new Label("<h3>Edit relevant document</h3>", Label.CONTENT_XHTML);
    editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table,
            additionalDocRefList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    final Button addContractReferenceBtn = new Button("Add Contract Reference");
    final Button removeContractReferenceBtn = new Button("Remove Contract Reference");
    removeContractReferenceBtn.setVisible(false);
    addContractReferenceBtn.setStyleName("marginLeft");
    removeContractReferenceBtn.setStyleName("marginLeft");

    addContractReferenceBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Panel panel = createInvoiceContractReference(removeContractReferenceBtn);
            topGridLayout.removeComponent(1, 0);
            topGridLayout.addComponent(panel, 1, 0);
            removeContractReferenceBtn.setVisible(true);
        }
    });

    removeContractReferenceBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            //remove the legal entity component panel
            Component c = removeContractReferenceBtn.getParent().getParent();
            topGridLayout.removeComponent(c);
            if (parent.getInvoice().getContractDocumentReference().size() > 0) {
                //parent.getInvoice().getContractDocumentReference().remove(0);
                parent.getInvoice().getContractDocumentReference().clear();
                ValidatorsList.removeListeners(Utils.getFieldListeners(contractReferenceForm));
            }

            topGridLayout.addComponent(addContractReferenceBtn, 1, 0);
        }
    });

    h.addComponent(buttonsContainer, 1, 0);
    topGridLayout.addComponent(addContractReferenceBtn, 1, 0);
    if (parent.getInvoice().getContractDocumentReference().size() > 0)
        addContractReferenceBtn.click();

    // ---- HIDDEN FORM BEGINS -----
    VerticalLayout formLayout = new VerticalLayout();
    formLayout.addComponent(hiddenContent);
    hiddenContent.setVisible(false);

    h.addComponent(formLayout, 0, 1);
    // ---- HIDDEN FORM ENDS -----

    setLayout(tabLayout);
}

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

/**
 * Simulates a click on the "Apply" button in the validation layout.
 * //from   w  w  w. j  a v  a 2  s.  c  o m
 */
public void button_ClickApply() throws Exception {
    boolean nodeCreated = !getLogger().openCommand("Apply");
    FocXMLLayout navigationLayout = getCurrentCentralPanel();

    if (navigationLayout != null) {
        FVValidationLayout validationLayout = navigationLayout.getValidationLayout();

        if (validationLayout != null) {
            Button apply = validationLayout.getApplyButton(false);
            if (Globals.isValo()) {
                apply = validationLayout.valo_GetApplyButton(false);
            }
            if (apply != null) {
                apply.click();
            } else {
                getLogger().addFailure("Apply button not found.");
            }
        } else {
            getLogger().addFailure("Validation layout not found");
        }
    } else {
        getLogger().addFailure("Navigation layout not found");
    }

    if (nodeCreated)
        getLogger().closeNode();
}

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

public void button_ClickSave() throws Exception {
    boolean nodeCreated = !getLogger().openCommand("Save");
    FocXMLLayout navigationLayout = getCurrentCentralPanel();

    if (navigationLayout != null) {
        FVValidationLayout validationLayout = navigationLayout.getValidationLayout();

        if (validationLayout != null) {
            Button save = validationLayout.getSaveButton(false);
            if (Globals.isValo()) {
                save = validationLayout.valo_GetSaveButton(false);
            }//from  w w w. j a  va2  s  . co m
            if (save != null) {
                save.click();
            } else {
                getLogger().addFailure("Save button not found.");
            }
        } else {
            getLogger().addFailure("Validation layout not found");
        }
    } else {
        getLogger().addFailure("Navigation layout not found");
    }
    if (nodeCreated)
        getLogger().closeNode();
}

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

/**
 * Simulates clicking on the "Apply" button in the validation layout until the apply button can't be found anymore.
 * //from www  .j  a v a  2  s  . c  om
 */
protected void button_ClickApplyRecursive() throws Exception {
    boolean keepLooping = true;

    while (keepLooping) {
        FocXMLLayout layout = getCurrentCentralPanel();

        if (layout != null) {
            FVValidationLayout validationLayout = layout.getValidationLayout();

            if (validationLayout != null) {
                Button apply = validationLayout.getApplyButton(false);

                if (apply != null) {
                    apply.click();
                } else {
                    keepLooping = false;
                }
            } else {
                keepLooping = false;
            }
        } else {
            keepLooping = false;
        }
    }
}

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

/**
 * Simulates a click on the "Discard" button in the validation layout.
 * //from  w w  w .j av  a  2s.com
 */
protected void button_ClickDiscard(String tableName) throws Exception {
    FocXMLLayout navigationLayout = getCurrentCentralPanel();

    if (tableName != null) {
        FVTableWrapperLayout tableWrapper = (FVTableWrapperLayout) findComponent(navigationLayout, tableName);
        if (tableWrapper != null) {
            ICentralPanel centralPanel = tableWrapper.innerLayout_GetICentralPanel();
            if (centralPanel != null) {
                navigationLayout = (FocXMLLayout) centralPanel;
            }
        }
    }

    if (navigationLayout != null) {
        FVValidationLayout validationLayout = navigationLayout.getValidationLayout();

        if (validationLayout != null) {
            Button discard = null;
            if (Globals.isValo()) {
                discard = validationLayout.valo_GetDiscardButton(false);
            } else {
                discard = validationLayout.getDiscardButton(false);
            }

            if (discard != null) {
                discard.click();
            } else {
                getLogger().addFailure("Discard button not found.");
            }
        } else {
            getLogger().addFailure("Validation layout not found");
        }
    } else {
        getLogger().addFailure("Navigation layout not found");
    }
}

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

/**
 * Simulates a click on the "Print" button in the validation layout.
 * /*from w w w. j  a  v a  2  s.c  o  m*/
 */
protected void button_ClickPrint() throws Exception {
    FocXMLLayout navigationLayout = getCurrentCentralPanel();
    if (navigationLayout != null) {
        FVValidationLayout validationLayout = navigationLayout.getValidationLayout();

        if (validationLayout != null) {
            Button print = validationLayout.getPrintButton(false);
            if (print != null) {
                print.click();
            } else {
                getLogger().addFailure("Print button not found.");
            }
        } else {
            getLogger().addFailure("Validation layout not found");
        }
    } else {
        getLogger().addFailure("Navigation layout not found");
    }
}

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

/**
 * Simulates a click on the "Full Screen" button in the validation layout.
 * // ww  w  .  j a  v a2s . c o  m
 */
protected void button_ClickFullScreen() throws Exception {
    FocXMLLayout navigationLayout = getCurrentCentralPanel();
    if (navigationLayout != null) {
        FVValidationLayout validationLayout = navigationLayout.getValidationLayout();

        if (validationLayout != null) {
            Button fullScreen = validationLayout.getFullScreenButton(false);
            if (fullScreen != null) {
                fullScreen.click();
            } else {
                getLogger().addFailure("Full screen button not found.");
            }
        } else {
            getLogger().addFailure("Validation layout not found");
        }
    } else {
        getLogger().addFailure("Navigation layout not found");
    }
}

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

/**
 * Simulates a click on the "Attach Image" button in the validation layout.
 * /*from  w  ww  . ja v a 2 s . c  o  m*/
 */
protected void button_ClickAttachment() throws Exception {
    FocXMLLayout navigationLayout = getCurrentCentralPanel();
    if (navigationLayout != null) {
        FVValidationLayout validationLayout = navigationLayout.getValidationLayout();

        if (validationLayout != null) {
            Button attach = validationLayout.getAttachButton(false);
            if (attach != null) {
                attach.click();
            } else {
                getLogger().addFailure("Attach image button not found.");
            }
        } else {
            getLogger().addFailure("Validation layout not found");
        }
    } else {
        getLogger().addFailure("Navigation layout not found");
    }
}

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

/**
 * Simulates a click on the "Back" button in the validation layout.
 * /*w  w w  .j  a  va2  s.  c  om*/
 */
protected void button_ClickBack() throws Exception {
    FocXMLLayout navigationLayout = getCurrentCentralPanel();
    if (navigationLayout != null) {
        FVValidationLayout validationLayout = navigationLayout.getValidationLayout();

        if (validationLayout != null) {
            Button back = validationLayout.getGoBackButton(false);
            if (back != null) {
                back.click();
            } else {
                getLogger().addFailure("Back button not found.");
            }
        } else {
            getLogger().addFailure("Validation layout not found");
        }
    } else {
        getLogger().addFailure("Navigation layout not found");
    }
}