Example usage for com.vaadin.ui VerticalLayout addComponent

List of usage examples for com.vaadin.ui VerticalLayout addComponent

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

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  av a  2s . 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();
}

From source file:at.peppol.webgui.app.MainWindow.java

License:Mozilla Public License

public void showInitialMainContent(UserFolder<?> userFolder) {
    // ------ START: Main Content -------
    final VerticalLayout mainContentLayout = new VerticalLayout();

    mainContentLayout.addStyleName("margin");
    final VerticalLayout topmain = new VerticalLayout();
    topmain.setSpacing(true);/*from   w w w . jav a2 s  .  co m*/
    topmain.setWidth("100%");
    final Label bigPAWGLabel = new Label("PEPPOL Post Award Web GUI");
    bigPAWGLabel.setStyleName("huge");
    topmain.addComponent(bigPAWGLabel);
    final Label blahContent = new Label(
            "This is a mockup of the GUI that is going" + " to be the PAWG. It is created by the Greek"
                    + " and Austrian teams as a fine replacement " + " of the Demo Client");
    blahContent.setWidth("80%");
    blahContent.addStyleName("big");
    //topmain.addComponent (blahContent);
    //HorizontalLayout itemsPanel = new ShowItemsPanel("Items", um, userFolder);

    final ShowItemsPanel itemsPanel = new ShowItemsPanel("Items", um, userFolder);
    this.itemsPanel = itemsPanel;
    topmain.addComponent(itemsPanel);
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setSpacing(true);
    topmain.addComponent(buttonsLayout);
    Button loadButton = new Button("Load invoice");
    //topmain.addComponent(loadButton);
    buttonsLayout.addComponent(loadButton);
    loadButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Table table = itemsPanel.getTable();
            if (table.getValue() != null) {
                //InvoiceType inv = (InvoiceType)table.getItem(table.getValue()).getItemProperty("invoice").getValue();
                //InvoiceBean invBean = (InvoiceBean)table.getItem(table.getValue());
                InvoiceBean invBean = ((InvoiceBeanContainer) table.getContainerDataSource())
                        .getItem(table.getValue()).getBean();
                //System.out.println("Invoice is: "+invBean);
                showInvoiceForm(invBean);
            }
        }
    });

    Button sendButton = new Button("Send invoice");
    buttonsLayout.addComponent(sendButton);
    sendButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            try {
                Table table = itemsPanel.getTable();
                if (table.getValue() != null) {
                    InvoiceBean invBean = ((InvoiceBeanContainer) table.getContainerDataSource())
                            .getItem(table.getValue()).getBean();
                    String path = invBean.getFolderEntryID();
                    FileSystemResource s = new FileSystemResource(path);
                    SendInvoice.sendDocument(s);

                    //file is sent. move invoice to outbox
                    um.moveInvoice(invBean, um.getDrafts(), um.getOutbox());
                    //itemsPanel.getTable().requestRepaint();
                    itemsPanel.init(um.getDrafts());
                }
            } catch (FileNotFoundException e) {
                getWindow().showNotification("Could not find invoice file", Notification.TYPE_ERROR_MESSAGE);
            } catch (Exception e) {
                getWindow().showNotification("Could not send invoice. AP connection error",
                        Notification.TYPE_ERROR_MESSAGE);
                e.printStackTrace();
            }
        }
    });

    final Button learnMoreBtn = new Button("Learn More >>");
    learnMoreBtn.addStyleName("tall default");
    //topmain.addComponent (learnMoreBtn);

    mainContentLayout.addComponent(topmain);
    // ------ END: Main Content ---------
    mainContentLayout.setHeight("100%");
    mainContentLayout.setSizeFull();

    mainContentLayout.setSpacing(true);
    mainContentLayout.setWidth("100%");
    middleContentLayout.setWidth("100%");
    middleContentLayout.setHeight("100%");
    middleContentLayout.setMargin(true);
    // --------
    addComponent(middleContentLayout);
    addComponent(footerLayout);
    if (mainContentComponent != null) {
        middleContentLayout.replaceComponent(mainContentComponent, mainContentLayout);
    } else {
        middleContentLayout.addComponent(mainContentLayout);
    }
    middleContentLayout.setExpandRatio(mainContentLayout, 1);
    mainContentComponent = mainContentLayout;
}

From source file:at.punkt.lodms.web.dialog.AboutDialog.java

License:GNU General Public License

public AboutDialog() {
    super("About Open Data Interoperability Platform");
    Label aboutText = new Label("<div class=\"lodms_about\" style=\"width:705px;white-space: normal;\">"
            + "<p>The Open Data Interoperability Platform (ODIP) is developed <a href=\"http://tenforce.com\">Tenforce</a> in the context of <a href=\"http://www.opendatasupport.eu\">Open Data Support</a>, a project funded by <a href=\"http://ec.europa.eu/dgs/connect/\">DG CONNECT</a> of the European Commission underSMART 2012/0107Lot 2:Provision of services for the Publication, Access and Reuse of Open Public Data across the European Union, through existing open data portals(Contract No. 30-CE-0530965/00-17).</p>"
            + "<p><a href=\"http://www.opendatasupport.eu\">Open Data Support</a> is run by <a href=\"http://www.pwc.com/gx/en/eu-institutions-services/index.jhtml\">PwC EU Services</a>.</p>"
            + "<p>The Linked (Open) Data Management Suite is developed by the <a href=\"http://www.semantic-web.at\">Semantic Web Company</a> in the course of the <a href=\"http://lod2.eu\">LOD2</a> FP7 project.</p>"
            + "<p>It is a Java based Linked (Open) Data Management Suite to schedule and monitor required ETL: Extract - Transform - Load</br>jobs for smooth and efficient Linked (Open) Data Management for web-based Linked Open Data portals (LOD platforms)</br>as well as for sustainable Data Management and Data Integration usage inside of the enterprise / the organisation.</p>"
            + "<p>Release 1.0, <a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GPLv2</a></div>",
            Label.CONTENT_XHTML);
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/* w  w  w  .jav a2 s  .c  om*/
    layout.setSpacing(true);
    layout.addComponent(aboutText);
    layout.setSizeUndefined();
    setContent(layout);
    center();
}

From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.topic.accounting.AccountingQuestionManager.java

License:LGPL

@Override
public void startQuiz() {
    // Remove everything from the layout, save it for displaying after
    // clicking OK
    final Component[] components = new Component[getComponentCount()];
    for (int i = 0; i < components.length; i++) {
        components[i] = getComponent(i);
    }//from   www.  j  a v a 2s. c o  m
    removeAllComponents();
    // Create first page
    VerticalLayout layout = new VerticalLayout();

    addComponent(layout);
    Label label = new Label("Answer all the questions like you were working for \"Unternehmen XY\"",
            ContentMode.HTML);
    Button cont = new Button("Continue", e -> {
        removeAllComponents();
        for (Component c : components) {
            addComponent(c);
        }
        super.startQuiz();
    });
    layout.addComponent(components[0]);// Title of the quiz
    layout.addComponent(label);
    layout.addComponent(cont);
    layout.setComponentAlignment(components[0], Alignment.MIDDLE_CENTER);

}

From source file:au.org.scoutmaster.views.ContactView.java

@Override
protected VerticalLayout buildEditor(final ValidatingFieldGroup<Contact> fieldGroup2) {
    this.tabs.setSizeFull();

    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();/*w w w . j  a  v a  2 s .co m*/

    // this needs to be updated when the contact changes
    this.changeListener = new ChangeListener();

    overviewTab();
    // contactTab();
    relationshipTab();
    youthTab();
    memberTab();
    medicalTab();
    backgroundTab();
    logTab();
    noteTab();
    // googleTab();

    // When a persons birth date changes recalculate their age.
    this.birthDate.addValueChangeListener(this.changeListener);

    layout.addComponent(this.tabs);
    // VerticalLayout c = new VerticalLayout();
    // layout.addComponent(c);
    // layout.setExpandRatio(c, 1);

    return layout;
}

From source file:au.org.scoutmaster.views.ContactView.java

@Override
protected AbstractLayout getAdvancedSearchLayout() {
    final VerticalLayout advancedSearchLayout = new VerticalLayout();
    advancedSearchLayout.setSpacing(true);

    final HorizontalLayout tagSearchLayout = new HorizontalLayout();
    this.tagSearchField = new TagField("Search Tags", true);
    tagSearchLayout.addComponent(this.tagSearchField);

    tagSearchLayout.setSizeFull();/*from   www. j  a v a2  s. co  m*/
    advancedSearchLayout.addComponent(tagSearchLayout);

    final HorizontalLayout stringSearchLayout = new HorizontalLayout();
    stringSearchLayout.addComponent(this.searchField);
    stringSearchLayout.setWidth("100%");

    advancedSearchLayout.addComponent(stringSearchLayout);

    final Button searchButton = new Button("Search");
    final Action1<ClickEvent> searchClickAction = new SearchClickAction();
    ButtonEventSource.fromActionOf(searchButton).subscribe(searchClickAction);

    advancedSearchLayout.addComponent(searchButton);
    advancedSearchLayout.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT);

    return advancedSearchLayout;

}

From source file:be.rvponp.build.CommitViewerUI.java

License:Apache License

@Override
protected void init(VaadinRequest vaadinRequest) {
    VerticalLayout layout = new VerticalLayout();

    VerticalLayout infoLayout = new VerticalLayout();
    layout.setSizeFull();/*from  ww  w. ja  v a  2  s. co m*/
    HorizontalLayout buildDateLayout = createBuildDateLayout();
    infoLayout.addComponent(buildDateLayout);

    table = createCommitsTable();
    files = new VerticalLayout();
    Label filesLabel = new Label("Files");
    VerticalLayout filesLayout = new VerticalLayout();

    HorizontalLayout filtersLayout = createFiltersLayout(table, files, filesLayout);

    VerticalLayout tableLayout = new VerticalLayout();
    tableLayout.addComponent(table);
    tableLayout.setSizeFull();

    filesLayout.addComponent(filesLabel);
    filesLayout.addComponent(files);
    filesLayout.setVisible(false);
    filesLayout.setSizeFull();
    infoLayout.addComponent(new Panel(filtersLayout));
    infoLayout.setSizeUndefined();

    layout.addComponent(infoLayout);
    layout.addComponent(tableLayout);
    layout.setExpandRatio(tableLayout, 1);
    layout.addComponent(filesLayout);
    layout.setExpandRatio(filesLayout, 0);

    layout.addComponent(new ExportXLSButton("Export XLS", table, fromVersion, toVersion));
    layout.setMargin(true);
    setContent(layout);

}

From source file:by.bigvova.LoginUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("Vaadin Shared Security Demo Login");

    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();//from  ww w . j av a2 s . c  o  m

    userName = new TextField("Username");
    passwordField = new PasswordField("Password");
    rememberMe = new CheckBox("Remember me");
    login = new Button("Login");
    Label label = new Label("Name: User / Password: password");
    loginForm.addComponent(userName);
    loginForm.addComponent(passwordField);
    loginForm.addComponent(rememberMe);
    loginForm.addComponent(login);
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            login();
        }
    });

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSpacing(true);
    loginLayout.setSizeUndefined();

    if (request.getParameter("logout") != null) {
        loggedOutLabel = new Label("You have been logged out!");
        loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS);
        loggedOutLabel.setSizeUndefined();
        loginLayout.addComponent(loggedOutLabel);
        loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER);
    }

    loginLayout.addComponent(loginFailedLabel = new Label());
    loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER);
    loginFailedLabel.setSizeUndefined();
    loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    loginFailedLabel.setVisible(false);

    loginLayout.addComponent(label);
    loginLayout.addComponent(loginForm);
    loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

    VerticalLayout rootLayout = new VerticalLayout(loginLayout);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER);
    setContent(rootLayout);
    setSizeFull();
}

From source file:by.bigvova.ui.LoginUI.java

License:Apache License

private VerticalLayout root() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from   w  ww  .java  2  s . c om

    Component loginForm = buildLoginForm();
    layout.addComponent(loginForm);
    layout.setComponentAlignment(loginForm, Alignment.MIDDLE_CENTER);
    return layout;
}

From source file:by.bigvova.ui.LoginUI.java

License:Apache License

private Component buildLoginForm() {
    final VerticalLayout loginPanel = new VerticalLayout();
    loginPanel.setSizeUndefined();/*from  w w  w . j  a v a 2 s .  c  om*/
    loginPanel.setSpacing(true);
    Responsive.makeResponsive(loginPanel);
    loginPanel.addStyleName("login-panel");

    loginPanel.addComponent(buildLabels());
    loginPanel.addComponent(buildFields());
    return loginPanel;
}