List of usage examples for com.vaadin.ui Panel requestRepaintAll
@Override @Deprecated public void 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);// w ww. j a v a 2 s . c om } 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(); }