Example usage for com.vaadin.ui Label Label

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

Introduction

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

Prototype

public Label(String text, ContentMode contentMode) 

Source Link

Document

Creates a new instance with the given text and content mode.

Usage

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

License:Mozilla Public License

private void initElements() {

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);/*from w ww  . j a  va  2  s . c o  m*/
    hiddenContent.setMargin(true);

    table = new InvoiceLineCommodityClassificationTable(lineCommodityList);
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

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

    InvoiceLineCommodityClassificationTableEditor editor = new InvoiceLineCommodityClassificationTableEditor(
            editMode);
    Label label = new Label("<h3>Adding commodity classification line</h3>", Label.CONTENT_XHTML);
    addButton.addListener(
            editor.addButtonListener(editButton, deleteButton, hiddenContent, table, lineCommodityList, label));
    label = new Label("<h3>Edit commodity classification line</h3>", Label.CONTENT_XHTML);
    editButton.addListener(
            editor.editButtonListener(addButton, deleteButton, hiddenContent, table, lineCommodityList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    Panel outerPanel = new Panel(prefix + " Commodity Classifications");
    //outerPanel.setStyleName("light");     

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

    grid.setSizeUndefined();
    grid.addComponent(tableContainer, 0, 0);
    grid.addComponent(buttonsContainer, 1, 0);

    outerPanel.addComponent(grid);
    outerPanel.addComponent(formLayout);
    outerLayout.addComponent(outerPanel);
    outerPanel.requestRepaintAll();

    VerticalLayout mainLayout = new VerticalLayout();
    final VerticalLayout showHideContentLayout = new VerticalLayout();
    showHideContentLayout.addComponent(outerPanel);
    HorizontalLayout showHideButtonLayout = new HorizontalLayout();
    Button btn = new Button("Show/Hide Allowances/Charges", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub
            showHideContentLayout.setVisible(!showHideContentLayout.isVisible());
        }
    });
    showHideButtonLayout.setWidth("100%");
    showHideButtonLayout.addComponent(btn);
    showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT);

    //mainLayout.addComponent(showHideButtonLayout);
    mainLayout.addComponent(showHideContentLayout);
    //showHideContentLayout.setVisible(false);    

    addComponent(mainLayout);

}

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

License:Mozilla Public License

private void initElements() {

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);//from   ww w  .  j a  va 2 s  .  c  o m
    hiddenContent.setMargin(true);

    table = new InvoiceLineOrderReferenceTable(lineOrderList);
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

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

    InvoiceLineOrderReferenceTableEditor editor = new InvoiceLineOrderReferenceTableEditor(editMode);
    Label label = new Label("<h3>Adding order line</h3>", Label.CONTENT_XHTML);
    addButton.addListener(
            editor.addButtonListener(editButton, deleteButton, hiddenContent, table, lineOrderList, label));
    label = new Label("<h3>Edit order line</h3>", Label.CONTENT_XHTML);
    editButton.addListener(
            editor.editButtonListener(addButton, deleteButton, hiddenContent, table, lineOrderList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    Panel outerPanel = new Panel(prefix + " Referencing Orders");
    //outerPanel.setStyleName("light");     

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

    grid.setSizeUndefined();
    grid.addComponent(tableContainer, 0, 0);
    grid.addComponent(buttonsContainer, 1, 0);

    outerPanel.addComponent(grid);
    outerPanel.addComponent(formLayout);
    outerLayout.addComponent(outerPanel);
    outerPanel.requestRepaintAll();

    VerticalLayout mainLayout = new VerticalLayout();
    final VerticalLayout showHideContentLayout = new VerticalLayout();
    showHideContentLayout.addComponent(outerPanel);
    HorizontalLayout showHideButtonLayout = new HorizontalLayout();
    Button btn = new Button("Show/Hide Allowances/Charges", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub
            showHideContentLayout.setVisible(!showHideContentLayout.isVisible());
        }
    });
    showHideButtonLayout.setWidth("100%");
    showHideButtonLayout.addComponent(btn);
    showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT);

    //mainLayout.addComponent(showHideButtonLayout);
    mainLayout.addComponent(showHideContentLayout);
    //showHideContentLayout.setVisible(false);    

    addComponent(mainLayout);

}

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

License:Mozilla Public License

private void initElements() {
    supplierForm = new PartyDetailForm("Supplier", supplier.getParty());
    supplierForm.setImmediate(true);/*  www . j a v a2 s . c  o  m*/
    customerForm = new PartyDetailForm("Customer", customer.getParty());
    customerForm.setImmediate(true);
    //supplierForm.setSizeFull ();
    //customerForm.setSizeFull ();

    final HorizontalLayout footerLayout = new HorizontalLayout();
    footerLayout.setSpacing(true);
    footerLayout.setMargin(true);
    footerLayout.addComponent(new Button("Save Invoice", new Button.ClickListener() {

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            SetCommonCurrency();
            ValidatorHandler vh = new ValidatorHandler(footerLayout);
            AbstractUBLDocumentMarshaller.setGlobalValidationEventHandler(vh);
            vh.clearErrors();
            clearTabErrorStyles();
            boolean invoiceHasErrors = false;

            List<ValidationError> errors = GlobalValidationsRegistry.runAll();
            if (errors.size() > 0) {
                invoiceHasErrors = true;
                Window errorWindow = new Window("Errors");
                //position and size of the window
                errorWindow.setPositionX(200);
                errorWindow.setPositionY(200);
                errorWindow.setWidth("600px");
                errorWindow.setHeight("300px");

                //add the error messages
                String errorMessage = "<ol>";
                for (int i = 0; i < errors.size(); i++) {
                    errorMessage += "<li style=\"margin-top: 4px;\"><b>" + errors.get(i).getRuleID() + "</b>: "
                            + errors.get(i).getErrorInfo() + "</li>";
                    //mark the appropriate Tab as error
                    Tab tab = invTabSheet.getTab(errors.get(i).getMainComponent());
                    if (tab != null)
                        tab.setStyleName("test111");
                }
                errorMessage += "</ol>";
                errorWindow.addComponent(new Label(errorMessage, Label.CONTENT_XHTML));

                //show the error window
                getParent().getWindow().addWindow(errorWindow);
                errors.clear();
            }

            ValidatorsList.validateListenersNotify();
            if (ValidatorsList.validateListeners() == false) {
                invoiceHasErrors = true;
            }

            if (invoiceHasErrors) {
                getWindow().showNotification("Validation error. Could not save invoice",
                        Notification.TYPE_TRAY_NOTIFICATION);
            } else {
                try {
                    if (invoiceFilePath.equals("")) {
                        UBL20DocumentMarshaller.writeInvoice(invoice,
                                new StreamResult(new File(um.getDrafts().getFolder().toString()
                                        + System.getProperty("file.separator") + "invoice"
                                        + System.currentTimeMillis() + ".xml")));
                        invoiceFilePath = um.getDrafts().getFolder().toString()
                                + System.getProperty("file.separator") + "invoice" + System.currentTimeMillis()
                                + ".xml";
                    } else {
                        UBL20DocumentMarshaller.writeInvoice(invoice,
                                new StreamResult(new File(invoiceFilePath)));
                    }
                    getWindow()
                            .showNotification(
                                    "Validation passed. Invoice saved in "
                                            + um.getDrafts().getName().toUpperCase() + " folder",
                                    Notification.TYPE_TRAY_NOTIFICATION);
                } catch (Exception e) {
                    getWindow().showNotification("Disk access error. Could not save invoice",
                            Notification.TYPE_ERROR_MESSAGE);
                }
            }

            /*PEPPOL validation
             * final ValidationPyramid vp = new ValidationPyramid (EValidationDocumentType.INVOICE,
                    ValidationTransaction.createUBLTransaction (ETransaction.T10));
             final List <ValidationPyramidResultLayer> aResults = vp.applyValidation (new FileSystemResource ("invoice.xml"))
                   .getAllValidationResultLayers ();
             if (aResults.isEmpty ())
               System.out.println ("  The document is valid!");
             else
               for (final ValidationPyramidResultLayer aResultLayer : aResults)
                 for (final IResourceError aError : aResultLayer.getValidationErrors ())
                   System.out.println ("  " + aResultLayer.getValidationLevel () + " " + aError.getAsString (Locale.US));
            */
            /*ValidatorsList.validateListenersNotify();
            if (ValidatorsList.validateListeners() == false) {
               getParent().getWindow().showNotification("Validation error... ",Notification.TYPE_TRAY_NOTIFICATION);
            }
            else
               getParent().getWindow().showNotification("Validation passed! ",Notification.TYPE_TRAY_NOTIFICATION);
            */

        }
    }));

    /*    footerLayout.addComponent (new Button ("Save Invoice", new Button.ClickListener () {
            
          @Override
          public void buttonClick (final Button.ClickEvent event) {
            try {
              SetCommonCurrency ();          
              System.out.println (invoice.getDelivery ().get (0).getDeliveryAddress ().getStreetName ().getValue ());
            }
            catch (final Exception ex) {
              LOGGER.error ("Error creating files. ", ex);
            }
          }
        }));
    */
    footerLayout.addComponent(new Button("Read Invoice from disk", new Button.ClickListener() {

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            try {
                SetCommonCurrency();
                InvoiceType inv = UBL20DocumentMarshaller
                        .readInvoice(new StreamSource(new FileInputStream(new File("invoice.xml"))));
            } catch (final Exception ex) {
                LOGGER.error("Error creating files. ", ex);
            }
        }
    }));

    getFooter().addComponent(footerLayout);

}

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

License:Mozilla Public License

private void initElements() {

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);/*from   w w  w .  ja v a 2s  .  c o m*/
    hiddenContent.setMargin(true);

    table = new InvoiceItemPropertyTable(itemPropertyBeanList);
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

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

    InvoiceItemPropertyTableEditor editor = new InvoiceItemPropertyTableEditor(editMode);
    Label label = new Label("<h3>Adding new item property</h3>", Label.CONTENT_XHTML);
    addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table,
            itemPropertyBeanList, label));
    label = new Label("<h3>Edit item property</h3>", Label.CONTENT_XHTML);
    editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table,
            itemPropertyBeanList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    Panel outerPanel = new Panel(itemPropertyPrefix + " Item Properties");
    //outerPanel.setStyleName("light");     

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

    grid.setSizeUndefined();
    grid.addComponent(tableContainer, 0, 0);
    grid.addComponent(buttonsContainer, 1, 0);

    outerPanel.addComponent(grid);
    outerPanel.addComponent(formLayout);
    outerLayout.addComponent(outerPanel);
    outerPanel.requestRepaintAll();

    VerticalLayout mainLayout = new VerticalLayout();
    final VerticalLayout showHideContentLayout = new VerticalLayout();
    showHideContentLayout.addComponent(outerPanel);
    HorizontalLayout showHideButtonLayout = new HorizontalLayout();
    Button btn = new Button("Show/Hide Additional Item Property", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub
            showHideContentLayout.setVisible(!showHideContentLayout.isVisible());
        }
    });
    showHideButtonLayout.setWidth("100%");
    showHideButtonLayout.addComponent(btn);
    showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT);

    //mainLayout.addComponent(showHideButtonLayout);
    mainLayout.addComponent(showHideContentLayout);
    //showHideContentLayout.setVisible(false);    

    addComponent(mainLayout);

}

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

License:Mozilla Public License

private void initElements() {
    allowanceChargeList = parent.getInvoice().getAllowanceCharge();

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);/*from   ww w. j a  v  a2  s  .  co m*/
    hiddenContent.setMargin(true);

    table = new InvoiceAllowanceChargeTable(parent.getInvoice().getAllowanceCharge());
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(true);
    table.addStyleName("striped strong");

    //table.addListener(parent.new TaxExclusiveAmountListener());

    final VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

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

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

    InvoiceAllowanceChargeTableEditor editor = new InvoiceAllowanceChargeTableEditor(editMode,
            parent.getInvoice());
    Label label = new Label("<h3>Adding new allowance/charge line</h3>", Label.CONTENT_XHTML);
    addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table,
            allowanceChargeList, label));
    label = new Label("<h3>Edit allowance/charge line</h3>", Label.CONTENT_XHTML);
    editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table,
            allowanceChargeList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    final Panel outerPanel = new Panel("Allowance Charge");

    grid.addComponent(tableContainer, 0, 0);
    grid.addComponent(buttonsContainer, 1, 0);

    outerPanel.addComponent(grid);
    outerLayout.addComponent(outerPanel);

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

    setLayout(outerLayout);
    grid.setSizeUndefined();
    outerPanel.requestRepaintAll();
}

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);//from  w w  w  .  j a  v a  2s.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:at.peppol.webgui.app.components.TabInvoiceLine.java

License:Mozilla Public License

private void initElements() {
    invoiceLineList = parent.getInvoice().getInvoiceLine();

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);//from   w  w w .  j a v a 2  s .c o m
    hiddenContent.setMargin(true);

    table = new InvoiceLineTable(parent.getInvoice().getInvoiceLine());
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    //table.addListener(parent.new LinesTotalAmountListener());
    //table.addListener(parent.new TaxExclusiveAmountListener());

    final VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

    // buttons Add, Edit, Delete
    final Button addBtn = new Button("Add new");
    final Button editBtn = new Button("Edit selected");
    final Button deleteBtn = new Button("Delete Selected");

    addBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            addBtn.setEnabled(false);
            editBtn.setEnabled(false);
            deleteBtn.setEnabled(false);
            //addMode = true;
            hiddenContent.removeAllComponents();
            invoiceLineItem = createInvoiceLineItem();

            final Label formLabel = new Label("<h3>Adding new invoice line</h3>", Label.CONTENT_XHTML);

            hiddenContent.addComponent(formLabel);
            final Form form = createInvoiceLineMainForm();
            hiddenContent.addComponent(form);

            HorizontalLayout h1 = new HorizontalLayout();
            h1.setSpacing(true);
            h1.setMargin(true);

            // Set invoiceLine 0..N cardinality panels
            //final Panel itemPropertyPanel = new ItemPropertyForm ("Additional",
            //                                                      invoiceLineItem.getInvLineAdditionalItemPropertyList ());
            final ItemPropertyForm itemPropertyPanel = new ItemPropertyForm("Additional",
                    invoiceLineItem.getInvLineAdditionalItemPropertyList());
            h1.addComponent(itemPropertyPanel);

            //add the allowance/charge indicator 0..N cardinality
            final InvoiceLineAllowanceChargeForm lineAllowanceChargePanel = new InvoiceLineAllowanceChargeForm(
                    "", invoiceLineItem.getAllowanceCharge(), parent.getInvoice());

            //add the listeners for line extension amount calculation
            BIIRULE_T10_R018 biirule_t10_r018 = new BIIRULE_T10_R018(invoiceLineItem, form);
            form.getField("Price Amount").addListener(biirule_t10_r018);
            form.getField("Base Quantity").addListener(biirule_t10_r018);
            form.getField("Invoiced Quantity").addListener(biirule_t10_r018);
            lineAllowanceChargePanel.getTable().addListener((ItemSetChangeListener) biirule_t10_r018);

            //add the listeners for VAT AE tax total amount
            EUGEN_T10_R018 eugen_t10_r018 = new EUGEN_T10_R018(form, "Tax Scheme ID", "Tax Category ID",
                    "Tax Total Amount");
            form.getField("Tax Scheme ID").addListener(eugen_t10_r018);
            form.getField("Tax Category ID").addListener(eugen_t10_r018);

            h1.addComponent(lineAllowanceChargePanel);

            HorizontalLayout h2 = new HorizontalLayout();
            h2.setSpacing(true);
            h2.setMargin(true);

            final Panel lineOrderPanel = new InvoiceLineOrderForm("", invoiceLineItem.getInvLineOrderList());

            h2.addComponent(lineOrderPanel);

            final Panel lineCommodityPanel = new InvoiceLineCommodityClassificationForm("",
                    invoiceLineItem.getInvLineCommodityClassificationList());

            h2.addComponent(lineCommodityPanel);

            hiddenContent.addComponent(h1);
            hiddenContent.addComponent(h2);

            // Save new line button
            final HorizontalLayout buttonLayout = new HorizontalLayout();
            buttonLayout.setSpacing(true);
            buttonLayout.addComponent(new Button("Save invoice line", new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    AbstractTextField itemName = (AbstractTextField) form.getField("Item Name");
                    itemName.setMaxLength(50);

                    if (itemName.getValue().toString().length() > 50) {
                        //itemName.setComponentError(new UserError("Item Name should not be more than 50 characters"));
                        itemName.setValue(itemName.getValue().toString().substring(0, 49));
                        getWindow().showNotification("Item Name truncated to 50 chars",
                                Notification.TYPE_TRAY_NOTIFICATION);
                    }

                    try {
                        /*Collection<String> props = (Collection<String>) form.getItemPropertyIds();
                        List<Field> fields = new ArrayList<Field>();
                        for (String property : props) {
                           fields.add(form.getField(property));
                        }
                        List<BlurListener> listeners = new ArrayList<BlurListener>();
                        for (Field f : fields) {
                           if (f instanceof AbstractTextField) {
                              AbstractTextField ff = (AbstractTextField)f;
                              listeners.addAll((Collection<BlurListener>) ff.getListeners(BlurEvent.class));
                           }
                        }
                        ValidatorsList.validateListenersNotify(listeners);
                        form.validate();*/
                        Utils.validateFormFields(form);
                        //form.commit();
                        // update table (and consequently add new item to invoiceList list)
                        table.addLine(invoiceLineItem);
                        //hide form
                        hiddenContent.setVisible(false);
                        //addMode = false;
                        addBtn.setEnabled(true);
                        editBtn.setEnabled(true);
                        deleteBtn.setEnabled(true);
                        //itemName.setComponentError(null);
                    } catch (InvalidValueException e) {
                        getWindow().showNotification("Invoice line has errors",
                                Notification.TYPE_TRAY_NOTIFICATION);
                    }

                }
            }));
            buttonLayout.addComponent(new Button("Cancel", new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    addBtn.setEnabled(true);
                    editBtn.setEnabled(true);
                    deleteBtn.setEnabled(true);
                    hiddenContent.removeAllComponents();
                    // hide form
                    hiddenContent.setVisible(false);
                    addMode = false;
                }
            }));

            hiddenContent.addComponent(buttonLayout);

            // hiddenContent.setVisible(!hiddenContent.isVisible());
            hiddenContent.setVisible(true);
        }
    });

    editBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            final Object rowId = table.getValue(); // get the selected rows id
            if (rowId != null) {
                addBtn.setEnabled(true);
                editBtn.setEnabled(true);
                deleteBtn.setEnabled(true);

                final String sid = (String) table.getContainerProperty(rowId, "ID.value").getValue();
                // TODO: PUT THIS IN FUNCTION BEGINS
                editMode = true;
                hiddenContent.removeAllComponents();

                // get selected item
                invoiceLineItem = (InvoiceLineAdapter) invoiceLineList.get(table.getIndexFromID(sid));
                // clone it to original item
                originalItem = new InvoiceLineAdapter();
                cloneInvoiceLineItem(invoiceLineItem, originalItem);

                final Label formLabel = new Label("<h3>Editing invoice line</h3>", Label.CONTENT_XHTML);

                hiddenContent.addComponent(formLabel);
                final Form form = createInvoiceLineMainForm();
                hiddenContent.addComponent(form);

                HorizontalLayout h1 = new HorizontalLayout();
                h1.setSpacing(true);
                h1.setMargin(true);
                // Set invoiceLine 0..N cardinality panels
                final ItemPropertyForm itemPropertyPanel = new ItemPropertyForm("Additional",
                        invoiceLineItem.getInvLineAdditionalItemPropertyList());
                h1.addComponent(itemPropertyPanel);

                //add the allowance/charge indicator 0..N cardinality
                final InvoiceLineAllowanceChargeForm lineAllowanceChargePanel = new InvoiceLineAllowanceChargeForm(
                        "", invoiceLineItem.getAllowanceCharge(), parent.getInvoice());

                //add the listeners for line extension amount calculation
                BIIRULE_T10_R018 biirule_t10_r018 = new BIIRULE_T10_R018(invoiceLineItem, form);
                form.getField("Price Amount").addListener(biirule_t10_r018);
                form.getField("Base Quantity").addListener(biirule_t10_r018);
                lineAllowanceChargePanel.getTable().addListener((ItemSetChangeListener) biirule_t10_r018);

                //add the listeners for VAT AE tax total amount
                EUGEN_T10_R018 eugen_t10_r018 = new EUGEN_T10_R018(form, "Tax Scheme ID", "Tax Category ID",
                        "Tax Total Amount");
                form.getField("Tax Scheme ID").addListener(eugen_t10_r018);
                form.getField("Tax Category ID").addListener(eugen_t10_r018);

                h1.addComponent(lineAllowanceChargePanel);

                HorizontalLayout h2 = new HorizontalLayout();
                h2.setSpacing(true);
                h2.setMargin(true);

                final Panel lineOrderPanel = new InvoiceLineOrderForm("",
                        invoiceLineItem.getInvLineOrderList());
                h2.addComponent(lineOrderPanel);

                final Panel lineCommodityPanel = new InvoiceLineCommodityClassificationForm("",
                        invoiceLineItem.getInvLineCommodityClassificationList());
                h2.addComponent(lineCommodityPanel);

                hiddenContent.addComponent(h1);
                hiddenContent.addComponent(h2);

                /*// Set invoiceLine 0..N cardinalily panels
                final Panel itemPropertyPanel = new ItemPropertyForm ("Additional",
                                                        invoiceLineItem.getInvLineAdditionalItemPropertyList ());
                hiddenContent.addComponent (itemPropertyPanel);*/

                // Save new line button
                final HorizontalLayout buttonLayout = new HorizontalLayout();
                buttonLayout.setSpacing(true);
                buttonLayout.addComponent(new Button("Save changes", new Button.ClickListener() {
                    @Override
                    public void buttonClick(final ClickEvent event) {
                        // update table (and consequently edit item to allowanceChargeList
                        // list)
                        AbstractTextField itemName = (AbstractTextField) form.getField("Item Name");
                        itemName.setMaxLength(50);

                        if (itemName.getValue().toString().length() > 50) {
                            //itemName.setComponentError(new UserError("Item Name should not be more than 50 characters"));
                            itemName.setValue(itemName.getValue().toString().substring(0, 49));
                            getWindow().showNotification("Item Name truncated to 50 chars",
                                    Notification.TYPE_TRAY_NOTIFICATION);
                        }

                        try {
                            /*Collection<String> props = (Collection<String>) form.getItemPropertyIds();
                            List<Field> fields = new ArrayList<Field>();
                            for (String property : props) {
                               fields.add(form.getField(property));
                            }
                            List<BlurListener> listeners = new ArrayList<BlurListener>();
                            for (Field f : fields) {
                               if (f instanceof AbstractTextField) {
                                  AbstractTextField ff = (AbstractTextField)f;
                                  listeners.addAll((Collection<BlurListener>) ff.getListeners(BlurEvent.class));
                               }
                            }
                            ValidatorsList.validateListenersNotify(listeners);
                            form.validate();*/
                            Utils.validateFormFields(form);
                            //table.setInvoiceLine (sid, invoiceLineItem);
                            table.setLine(sid, invoiceLineItem);
                            addBtn.setEnabled(true);
                            editBtn.setEnabled(true);
                            deleteBtn.setEnabled(true);
                            //    hide form
                            hiddenContent.setVisible(false);
                            editMode = false;
                        } catch (InvalidValueException e) {
                            getWindow().showNotification("Invoice line has errors",
                                    Notification.TYPE_TRAY_NOTIFICATION);
                        }
                    }
                }));
                buttonLayout.addComponent(new Button("Cancel editing", new Button.ClickListener() {
                    @Override
                    public void buttonClick(final ClickEvent event) {
                        hiddenContent.removeAllComponents();
                        addBtn.setEnabled(true);
                        editBtn.setEnabled(true);
                        deleteBtn.setEnabled(true);
                        //table.setInvoiceLine (sid, originalItem);
                        table.setLine(sid, originalItem);
                        // hide form
                        hiddenContent.setVisible(false);
                        editMode = false;
                    }
                }));

                hiddenContent.addComponent(buttonLayout);

                // hiddenContent.setVisible(!hiddenContent.isVisible());
                hiddenContent.setVisible(true);
                // TODO: PUT THIS IN FUNCTION ENDS
            } else {
                parent.getWindow().showNotification("Info", "No table line is selected",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
            }

        }
    });

    deleteBtn.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            final Object rowId = table.getValue(); // get the selected rows id
            if (rowId != null) {
                if (table.getContainerProperty(rowId, "ID.value").getValue() != null) {
                    final String sid = (String) table.getContainerProperty(rowId, "ID.value").getValue();
                    //table.removeInvoiceLine (sid);
                    table.removeLine(sid);
                }
            } else {
                parent.getWindow().showNotification("Info", "No table line is selected",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);

            }
        }
    });

    final VerticalLayout buttonsContainer = new VerticalLayout();
    buttonsContainer.setSpacing(true);
    buttonsContainer.addComponent(addBtn);
    buttonsContainer.addComponent(editBtn);
    buttonsContainer.addComponent(deleteBtn);

    final Panel outerPanel = new Panel("Invoice Line");

    grid.addComponent(tableContainer, 0, 0);
    grid.addComponent(buttonsContainer, 1, 0);

    outerPanel.addComponent(grid);
    outerLayout.addComponent(outerPanel);

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

    setLayout(outerLayout);
    grid.setSizeUndefined();
    outerPanel.requestRepaintAll();
}

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

License:Mozilla Public License

public Form createGridLayoutInvoiceLineForm() {
    Form form = new Form() {
        HorizontalLayout layout = new HorizontalLayout();
        Panel pricePanel = new Panel("Price");
        FormLayout f1 = new FormLayout();
        FormLayout f2 = new FormLayout();
        Label label = new Label("<h4>Allowances/Charges</h4>", Label.CONTENT_XHTML);
        {//from   ww  w.ja  v  a 2 s  .co m
            layout.setSpacing(true);
            layout.setMargin(true);
            setLayout(layout);
            HorizontalLayout h = new HorizontalLayout();
            h.setWidth("50px");
            pricePanel.setStyleName("light");
            layout.addComponent(f1);
            layout.addComponent(h);
            layout.addComponent(pricePanel);
            pricePanel.addComponent(f2);
        }

        @Override
        protected void attachField(Object propertyId, Field field) {
            //field.setCaption(null);
            if ("Line Note".equals(propertyId) || "Invoiced Quantity".equals(propertyId)
                    || "Line Extension Amount".equals(propertyId) || "Accounting Cost".equals(propertyId)
                    || "Tax Total Amount".equals(propertyId) || "Item Description".equals(propertyId)
                    || "Item Name".equals(propertyId) || "Sellers Item ID".equals(propertyId)
                    || "Tax Category ID".equals(propertyId) || "Tax Category Percent".equals(propertyId)
                    || "Standard Item ID".equals(propertyId) || "Tax Scheme ID".equals(propertyId)
                    || "Measurement Unit".equals(propertyId)) {

                f1.addComponent(field);
            } else if ("Price Allowance/Charge Indicator".equals(propertyId)
                    || "Price Allowance/Charge Reason".equals(propertyId)
                    || "Price Allowance/Charge Multiplier Factor".equals(propertyId)
                    || "Price Allowance/Charge Amount".equals(propertyId)
                    || "Price Allowance/Charge Base Amount".equals(propertyId)) {

                if (f2.getComponentIndex(label) == -1)
                    f2.addComponent(label);

                if ("Price Allowance/Charge Reason".equals(propertyId))
                    field.setCaption("Reason");
                else if ("Price Allowance/Charge Multiplier Factor".equals(propertyId))
                    field.setCaption("Multiplier Factor");
                else if ("Price Allowance/Charge Amount".equals(propertyId))
                    field.setCaption("Amount");
                else if ("Price Allowance/Charge Base Amount".equals(propertyId))
                    field.setCaption("Base Amount");

                f2.addComponent(field);
            } else { //for price amount and base quantity
                f2.addComponent(field);
            }
        }
    };

    return form;
}

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

License:Mozilla Public License

@SuppressWarnings("serial")
private void initElements() {
    editMode = false;//w  ww.  j  av  a 2 s  . c  o m
    paymentMeansList = parent.getInvoice().getPaymentMeans();
    //paymentMeansItem = createPaymentMeansItem();
    //paymentMeansList.add (paymentMeansItem);

    //paymentTermsList = parent.getInvoice().getPaymentTerms ();
    //PaymentTermsType pt = new PaymentTermsType();
    //paymentTermsList.add (pt);

    if (parent.getInvoice().getPaymentTerms().size() == 0) {
        paymentTermsItem = new PaymentTermsType();
        paymentTermsItem.getNote().add(new NoteType());
        parent.getInvoice().getPaymentTerms().add(paymentTermsItem);
    } else {
        paymentTermsItem = parent.getInvoice().getPaymentTerms().get(0);
    }

    //payeeParty = parent.getInvoice().getPayeeParty ();
    if (parent.getInvoice().getPayeeParty() == null) {
        payeeParty = createPayeePartyItem();
        parent.getInvoice().setPayeeParty(payeeParty);
    } else {
        payeeParty = parent.getInvoice().getPayeeParty();
    }
    //payeeParty = new PartyType();
    //payeeParty.setParty(new PartyType());

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

    final GridLayout grid = new GridLayout(2, 2);
    grid.setSpacing(true);
    //grid.setMargin(true);
    final VerticalLayout outerLayout = new VerticalLayout();

    final Panel outerPanel = new Panel("Payment");
    outerPanel.addComponent(grid);
    outerPanel.setScrollable(true);
    outerLayout.addComponent(outerPanel);

    final Panel invoiceDetailsPanel = new Panel("Payment Details");
    invoiceDetailsPanel.setStyleName("light");
    invoiceDetailsPanel.setSizeFull();
    //invoiceDetailsPanel.addComponent(createInvoicePaymentTopForm());
    //grid.addComponent(invoiceDetailsPanel, 0, 0);

    final Panel payeePartyPanel = new Panel("Payee Details");
    payeePartyPanel.setStyleName("light");
    payeePartyPanel.setSizeFull();
    payeePartyPanel.addComponent(createInvoicePayeePartyForm());
    //payeeForm = new PartyDetailForm("Payee", payeeParty);
    //payeePartyPanel.addComponent(payeeForm);
    grid.addComponent(payeePartyPanel, 0, 0);

    final Panel paymentTermsPanel = new Panel("Payment Terms");
    paymentTermsPanel.setStyleName("light");
    paymentTermsPanel.setSizeFull();
    paymentTermsPanel.addComponent(createInvoicePaymentTermsForm());
    grid.addComponent(paymentTermsPanel, 1, 0);

    final Panel paymentMeansPanel = new Panel("Payment Means");
    VerticalLayout paymentMeansLayout = new VerticalLayout();
    paymentMeansPanel.setContent(paymentMeansLayout);
    paymentMeansPanel.setStyleName("light");
    paymentMeansPanel.setSizeFull();
    paymentMeansLayout.setSpacing(true);
    paymentMeansLayout.setMargin(true);

    table = new PaymentMeansTable(paymentMeansList);
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(200, UNITS_PIXELS);
    table.setSizeFull();
    table.setWidth("80%");
    table.setFooterVisible(false);
    table.addStyleName("striped strong");

    HorizontalLayout tableLayout = new HorizontalLayout();
    paymentMeansLayout.addComponent(tableLayout);
    paymentMeansLayout.addComponent(hiddenContent);
    hiddenContent.setVisible(false);

    VerticalLayout tableButtonsLayout = new VerticalLayout();
    tableButtonsLayout.setSpacing(true);
    tableButtonsLayout.setMargin(true);
    final Button addButton = new Button("Add new");
    final Button editButton = new Button("Edit selected");
    final Button deleteButton = new Button("Delete selected");
    tableButtonsLayout.addComponent(addButton);
    tableButtonsLayout.addComponent(editButton);
    tableButtonsLayout.addComponent(deleteButton);

    tableLayout.addComponent(table);
    tableLayout.addComponent(tableButtonsLayout);

    outerPanel.addComponent(paymentMeansPanel);

    grid.setSizeUndefined();

    PaymentMeansTableEditor editor = new PaymentMeansTableEditor(editMode, parent.getInvoice());
    Label label = new Label("<h3>Adding new payments means</h3>", Label.CONTENT_XHTML);
    addButton.addListener(
            editor.addButtonListener(editButton, deleteButton, hiddenContent, table, paymentMeansList, label));
    label = new Label("<h3>Edit payment means line</h3>", Label.CONTENT_XHTML);
    editButton.addListener(
            editor.editButtonListener(addButton, deleteButton, hiddenContent, table, paymentMeansList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    setLayout(outerLayout);
    outerPanel.requestRepaintAll();
}

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

License:Mozilla Public License

@SuppressWarnings("serial")
private void initElements() {
    taxTotalList = parent.getInvoice().getTaxTotal();
    if (taxTotalList.size() == 0) {
        taxTotalItem = createTaxTotalItem();
        taxTotalList.add(taxTotalItem);//from   w  ww.j  a  v  a 2 s  . c  o m
    } else {
        taxTotalItem = taxTotalList.get(0);
    }

    //taxSubtotalList = parent.getInvoice ().getTaxTotal ().get (0).getTaxSubtotal ();
    taxSubtotalList = taxTotalItem.getTaxSubtotal();

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();
    hiddenContent = new VerticalLayout();
    hiddenContent.setSpacing(true);
    hiddenContent.setMargin(true);

    final Panel outerPanel = new Panel("Tax Total");
    outerPanel.addComponent(grid);
    outerPanel.setScrollable(true);
    outerLayout.addComponent(outerPanel);

    table = new InvoiceTaxSubtotalTable(taxTotalList.get(0).getTaxSubtotal());
    table.setSelectable(true);
    table.setImmediate(true);
    table.setNullSelectionAllowed(false);
    table.setHeight(150, UNITS_PIXELS);
    table.setFooterVisible(true);
    table.addStyleName("striped strong");
    final VerticalLayout tableContainer = new VerticalLayout();
    tableContainer.addComponent(table);
    tableContainer.setMargin(false, true, false, false);

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

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

    InvoiceTaxSubtotalTableEditor editor = new InvoiceTaxSubtotalTableEditor(editMode);
    Label label = new Label("<h3>Adding new tax subtotal</h3>", Label.CONTENT_XHTML);
    addButton.addListener(
            editor.addButtonListener(editButton, deleteButton, hiddenContent, table, taxSubtotalList, label));
    label = new Label("<h3>Edit tax subtotal</h3>", Label.CONTENT_XHTML);
    editButton.addListener(
            editor.editButtonListener(addButton, deleteButton, hiddenContent, table, taxSubtotalList, label));
    deleteButton.addListener(editor.deleteButtonListener(table));

    /*    // buttons Add, Edit, Delete
        final Button addBtn = new Button ("Add New", new Button.ClickListener () {
          @Override
          public void buttonClick (final Button.ClickEvent event) {
            
            addMode = true;
            hiddenContent.removeAllComponents ();
            taxSubtotalItem = createTaxSubtotalItem ();
            
            final Label formLabel = new Label ("<h3>Adding new tax subtotal line</h3>", Label.CONTENT_XHTML);
            
            hiddenContent.addComponent (formLabel);
            hiddenContent.addComponent (createInvoiceTaxSubtotalForm ());
            
            // Save new line button
            final HorizontalLayout buttonLayout = new HorizontalLayout ();
            buttonLayout.setSpacing (true);
            buttonLayout.addComponent (new Button ("Save tax subtotal line", new Button.ClickListener () {
              @Override
              public void buttonClick (final ClickEvent event) {
    // update table (and consequently add new item to taxSubtotalList
    // list)
    table.addTaxSubtotalLine (taxSubtotalItem);
    // hide form
    hiddenContent.setVisible (false);
    addMode = false;
            
    // update Total Tax Amount
    taxTotalItem.getTaxAmount ().setValue (SumTaxSubtotalAmount ());
            
    // update form as well
    // invoiceTaxTotalTopForm.getField("Tax Total Amount").setRequired(true);
    invoiceTaxTotalTopForm.getField ("Tax Total Amount").setValue (taxTotalItem.getTaxAmount ().getValue ());
              }
            }));
            buttonLayout.addComponent (new Button ("Cancel", new Button.ClickListener () {
              @Override
              public void buttonClick (final ClickEvent event) {
    hiddenContent.removeAllComponents ();
    // hide form
    hiddenContent.setVisible (false);
    addMode = false;
              }
            }));
            
            hiddenContent.addComponent (buttonLayout);
            
            // hiddenContent.setVisible(!hiddenContent.isVisible());
            hiddenContent.setVisible (true);
            
          }
        });
        final Button editBtn = new Button ("Edit Selected", new Button.ClickListener () {
          @Override
          public void buttonClick (final Button.ClickEvent event) {
            /*
             * Object rowId = table.getValue(); // get the selected rows id if(rowId
             * != null){ if(addMode || editMode){ parent.getWindow
             * ().showNotification("Info", "You cannot edit while in add/edit mode",
             * Window.Notification.TYPE_HUMANIZED_MESSAGE); return; } final String
             * sid =
             * (String)table.getContainerProperty(rowId,"ID.value").getValue(); //
             * TODO: PUT THIS IN FUNCTION BEGINS editMode = true;
             * hiddenContent.removeAllComponents (); //get selected item
             * allowanceChargeItem = (InvoiceAllowanceChargeAdapter)
             * allowanceChargeList.get (table.getIndexFromID (sid)); //clone it to
             * original item originalItem = new InvoiceAllowanceChargeAdapter ();
             * cloneInvoiceAllowanceChargeItem(allowanceChargeItem, originalItem);
             * Label formLabel = new Label("<h3>Editing allowance charge line</h3>",
             * Label.CONTENT_XHTML); hiddenContent.addComponent (formLabel);
             * hiddenContent.addComponent(createInvoiceAllowanceChargeForm());
             * //Save new line button HorizontalLayout buttonLayout = new
             * HorizontalLayout(); buttonLayout.setSpacing (true);
             * buttonLayout.addComponent(new Button("Save changes",new
             * Button.ClickListener(){
             * @Override public void buttonClick (ClickEvent event) { //update table
             * (and consequently edit item to allowanceChargeList list)
             * table.setAllowanceChargeLine (sid, allowanceChargeItem); //hide form
             * hiddenContent.setVisible(false); editMode = false; } }));
             * buttonLayout.addComponent(new Button("Cancel editing",new
             * Button.ClickListener(){
             * @Override public void buttonClick (ClickEvent event) {
             * hiddenContent.removeAllComponents (); table.setAllowanceChargeLine
             * (sid, originalItem); //hide form hiddenContent.setVisible(false);
             * editMode = false; } })); hiddenContent.addComponent(buttonLayout);
             * //hiddenContent.setVisible(!hiddenContent.isVisible());
             * hiddenContent.setVisible(true); // TODO: PUT THIS IN FUNCTION ENDS }
             * else { parent.getWindow ().showNotification("Info",
             * "No table line is selected",
             * Window.Notification.TYPE_HUMANIZED_MESSAGE); }
             */
    /*      }
        });
        editBtn.setEnabled (false);
        final Button deleteBtn = new Button ("Delete Selected", new Button.ClickListener () {
          @Override
          public void buttonClick (final Button.ClickEvent event) {
            
            final Object rowId = table.getValue (); // get the selected rows id
            if (rowId != null) {
              if (addMode || editMode) {
    parent.getWindow ().showNotification ("Info",
                                          "You cannot delete while in add/edit mode",
                                          Window.Notification.TYPE_HUMANIZED_MESSAGE);
    return;
              }
              if (table.getContainerProperty (rowId, "TableLineID").getValue () != null) {
    final String sid = (String) table.getContainerProperty (rowId, "TableLineID").getValue ();
    table.removeTaxSubtotalLine (sid);
            
    // update Total Tax Amount
    taxTotalItem.getTaxAmount ().setValue (SumTaxSubtotalAmount ());
            
    invoiceTaxTotalTopForm.getField ("Tax Total Amount").setValue (taxTotalItem.getTaxAmount ().getValue ());
            
              }
            }
            else {
              parent.getWindow ().showNotification ("Info",
                                        "No table line is selected",
                                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
            
            }
            
          }
        });*/

    final Panel invoiceDetailsPanel = new Panel("Tax Total Details");
    invoiceDetailsPanel.setStyleName("light");
    invoiceDetailsPanel.setSizeFull();
    invoiceDetailsPanel.addComponent(createInvoiceTaxTotalTopForm());

    table.addListener(new ItemSetChangeListener() {

        @Override
        public void containerItemSetChange(ItemSetChangeEvent event) {
            Field f = invoiceTaxTotalTopForm.getField(taxTotalAmount);
            f.setValue(addTaxSubTotals());
        }

    });

    grid.setSpacing(true);
    grid.addComponent(invoiceDetailsPanel, 0, 0);
    grid.addComponent(tableContainer, 0, 1);
    grid.addComponent(buttonsContainer, 1, 1);
    grid.setSizeUndefined();

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

    setLayout(outerLayout);
    outerPanel.requestRepaintAll();
}