Example usage for com.vaadin.ui VerticalLayout VerticalLayout

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

Introduction

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

Prototype

public VerticalLayout() 

Source Link

Document

Constructs an empty VerticalLayout.

Usage

From source file:com.github.moscaville.contactsdb.main.ContactsView.java

@PostConstruct
void init() {/*  www. j a  va2  s .  c om*/

    List<CategoryRecord> categories = categoryController.loadItems(100, 0, new CategoryRecord());
    List<LevelRecord> levels = levelController.loadItems(100, 0, new LevelRecord());
    List<RepresentativeRecord> representatives = representativeController.loadItems(100, 0,
            new RepresentativeRecord());

    contactTable = new ContactTable(controller, categories, levels, representatives);

    btnEdit = new Button("Edit");
    btnExport = new Button("Export");
    btnColumns = new Button("Columns");

    vLayout = new VerticalLayout();
    vLayout.setMargin(true);
    vControls = new HorizontalLayout();
    vControls.setSpacing(true);
    vControls.setMargin(true);
    vControls.addComponent(btnEdit);
    //vControls.addComponent(btnDuplicate);
    vControls.addComponent(btnExport);
    vControls.addComponent(btnColumns);
    hLayout.setSizeFull();

    //contactTable = new ContactTable();
    vLayout.addComponent(contactTable);
    vLayout.setHeight("75%");
    addComponent(vControls);
    addComponent(vLayout);
    setSizeFull();

    contactTable.addItemClickListener((ItemClickEvent event) -> {
        if (event.isDoubleClick()) {
            editContact(getSelectedContact());
        }
    });

    btnEdit.addClickListener((Button.ClickEvent event) -> {
        editContact(getSelectedContact());
    });

    btnColumns.addClickListener((Button.ClickEvent event) -> {
        contactTable.toggleVisibleColumns();
    });

    OnDemandFileDownloader fd = new OnDemandFileDownloader(
            new ExportOnDemandStreamResource(contactTable.getContainerDataSource()));
    fd.extend(btnExport);

}

From source file:com.github.moscaville.contactsdb.main.DetailView.java

@PostConstruct
private void init() {
    mainLayout = new VerticalLayout();
    mainLayout.setSpacing(true);//from w  w  w  .j  av a2 s  .  c o m

    nameLayout = new HorizontalLayout();
    nameLayout.setSpacing(true);
    companyName = createTextField("company name", nameLayout);
    firstName = createTextField("first name", nameLayout);
    lastName = createTextField("last name", nameLayout);

    emailPhoneLayout = new HorizontalLayout();
    emailPhoneLayout.setSpacing(true);
    email = createTextField("email", emailPhoneLayout);
    cellPhone = createTextField("cell phone", emailPhoneLayout);
    workPhone = createTextField("work phone", emailPhoneLayout);

    List<CategoryRecord> categoryRecords = categoryController.loadItems(100, 0, new CategoryRecord());
    categories = new ArrayList<>();
    if (categoryRecords != null) {
        categoryRecords.stream().forEach((categoryRecord) -> {
            if (categoryRecord.getName() != null) {
                categories.add(categoryRecord);
            }
        });
    }
    List<RepresentativeRecord> representativeRecords = representativeController.loadItems(100, 0,
            new RepresentativeRecord());
    representatives = new ArrayList<>();
    if (representativeRecords != null) {
        representativeRecords.stream().forEach((representativeRecord) -> {
            if (representativeRecord.getName() != null) {
                representatives.add(representativeRecord);
            }
        });
    }
    List<LevelRecord> levelRecords = levelController.loadItems(100, 0, new LevelRecord());
    levels = new ArrayList<>();
    if (levelRecords != null) {
        levelRecords.stream().forEach((levelRecord) -> {
            if (levelRecord.getName() != null) {
                levels.add(levelRecord);
            }
        });
    }

    classificationLayout = new HorizontalLayout();
    classificationLayout.setSpacing(true);
    category = createComboBox("Category", categories, classificationLayout);
    account = createComboBox("Account", representatives, classificationLayout);
    level = createComboBox("Level", levels, classificationLayout);

    addressLayout = new HorizontalLayout();
    addressLayout.setSpacing(true);
    addressLayout.setWidth("400px");
    address = createTextField("address", addressLayout);
    address.setWidth("90%");

    address2Layout = new HorizontalLayout();
    address2Layout.setSpacing(true);
    city = createTextField("city", address2Layout);
    state = createTextField("state", address2Layout);
    zip = createTextField("zip", address2Layout);

    notesLayout = new HorizontalLayout();
    notesLayout.setSpacing(true);
    notes = createNotesField("notes", notesLayout);

    buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    btnNew = new Button("New");
    btnNew.addClickListener((Button.ClickEvent event) -> {
        contact = new ContactRecord();
        bind(contact);
    });
    buttonLayout.addComponent(btnNew);
    btnSave = new Button("Save");
    btnSave.addClickListener((Button.ClickEvent event) -> {
        if (fieldGroup.isModified()) {
            try {
                fieldGroup.commit();
            } catch (FieldGroup.CommitException ex) {
                Logger.getLogger(DetailView.class.getName()).log(Level.SEVERE, null, ex);
            }
            RecordWrapper<ContactRecord> recordWrapper = new RecordWrapper();
            recordWrapper.setFields(contact);
            controller.saveItem(recordWrapper, contact.getId());
            enableButtons(false);
        }
    });
    buttonLayout.addComponent(btnSave);
    btnCancel = new Button("Cancel");
    btnCancel.addClickListener((Button.ClickEvent event) -> {
        fieldGroup.discard();
        enableButtons(false);
    });
    buttonLayout.addComponent(btnCancel);
    btnDuplicate = new Button("Duplicate");
    btnDuplicate.addClickListener((Button.ClickEvent event) -> {
        ContactRecord duplicate;
        try {
            duplicate = (ContactRecord) BeanUtils.cloneBean(contact);
            duplicate.setId(null);
            contact = duplicate;
            bind(contact);
            btnSave.setEnabled(false);
            btnCancel.setEnabled(false);
        } catch (IllegalAccessException | InstantiationException | InvocationTargetException
                | NoSuchMethodException ex) {
            Logger.getLogger(DetailView.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    buttonLayout.addComponent(btnDuplicate);
    btnDelete = new Button("Delete");
    btnDelete.addClickListener((Button.ClickEvent event) -> {
        ConfirmDialog.show(MainUI.getCurrent(), "Are you sure?", (ConfirmDialog dialog) -> {
            if (dialog.isConfirmed()) {
                controller.deleteItem(contact.getId());
            }
        });
    });
    buttonLayout.addComponent(btnDelete);
    mainLayout.addComponent(nameLayout);
    mainLayout.addComponent(classificationLayout);
    mainLayout.addComponent(emailPhoneLayout);
    mainLayout.addComponent(addressLayout);
    mainLayout.addComponent(address2Layout);
    mainLayout.addComponent(notesLayout);
    mainLayout.addComponent(buttonLayout);
    addComponent(mainLayout);
    bind(MainUI.get().getContact());
}

From source file:com.github.moscaville.contactsdb.ui.ContactsPanel.java

private void init() {

    setImmediate(true);//from www.  j  a v a  2s .c  om
    firstName = new TextField("First Name");
    vl = new VerticalLayout();
    vl.addComponent(firstName);
    setContent(vl);
}

From source file:com.github.peholmst.i18n4vaadin.cdi.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);/*  w w  w  .  j  a  va2s .co  m*/
    content.setSpacing(true);
    content.setSizeFull();
    setContent(content);

    languageChanger = new ComboBox();
    languageChanger.setContainerDataSource(
            new BeanItemContainer<java.util.Locale>(java.util.Locale.class, i18n.getSupportedLocales()));
    languageChanger.setImmediate(true);
    languageChanger.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (languageChanger.getValue() != null) {
                i18n.setLocale((java.util.Locale) languageChanger.getValue());
            }
        }
    });
    content.addComponent(languageChanger);

    Panel viewContent = new Panel();
    viewContent.setSizeFull();
    content.addComponent(viewContent);
    content.setExpandRatio(viewContent, 1);

    Navigator navigator = new Navigator(this, viewContent);
    navigator.addProvider(viewProvider);
    navigator.navigateTo("demo");
    setNavigator(navigator);

    updateStrings();
}

From source file:com.github.peholmst.i18n4vaadin.simple.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);/*from   w  w  w .ja v a2 s  . c o m*/
    content.setSpacing(true);
    content.setSizeFull();
    setContent(content);

    languageChanger = new ComboBox();
    languageChanger.setContainerDataSource(
            new BeanItemContainer<java.util.Locale>(java.util.Locale.class, i18n.getSupportedLocales()));
    languageChanger.setImmediate(true);
    languageChanger.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (languageChanger.getValue() != null) {
                i18n.setLocale((java.util.Locale) languageChanger.getValue());
            }
        }
    });
    content.addComponent(languageChanger);

    Panel viewContent = new Panel();
    viewContent.setSizeFull();
    content.addComponent(viewContent);
    content.setExpandRatio(viewContent, 1);

    Navigator navigator = new Navigator(this, viewContent);
    navigator.addView("demo", DemoView.class);
    navigator.navigateTo("demo");
    setNavigator(navigator);

    updateStrings();
}

From source file:com.github.peholmst.springsecuritydemo.ui.CategoryBrowser.java

License:Apache License

/**
 * Creates the category browser component.
 */// ww  w.  jav a  2s. c o  m
@SuppressWarnings("serial")
private void createComponent() {
    categoryContainer = new CategoryContainer(getCategoryService());
    categoryContainer.refresh();

    /*
     * The tree will show all the categories returned from the category
     * service.
     */
    categoryTree = new Tree();
    {
        categoryTree.setSizeFull();
        categoryTree.setContainerDataSource(categoryContainer);
        categoryTree.setItemCaptionPropertyId("name");
        categoryTree.setImmediate(true);
    }

    /*
     * The form for editing categories is hidden by default and is shown
     * when the user clicks the edit or add button.
     */
    categoryForm = new CategoryForm();

    /*
     * The toolbar will be placed at the bottom of the browser and contains
     * buttons for refreshing the category tree, and adding, editing and
     * removing categories.
     */
    final HorizontalLayout toolbar = new HorizontalLayout();
    {
        /*
         * Button: Refresh the category browser
         */
        refreshButton = new Button();
        refreshButton.setIcon(new ThemeResource("icons/16/refresh.png"));
        refreshButton.setStyleName("small");
        refreshButton.setDescription(getI18nProvider().getMessage("categories.refresh.descr"));
        refreshButton.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                actionRefresh();
            }
        });
        toolbar.addComponent(refreshButton);

        /*
         * Button: Add a new category. The currently selected category will
         * be used as parent.
         */
        addButton = new Button();
        addButton.setIcon(new ThemeResource("icons/16/add.png"));
        addButton.setStyleName("small");
        addButton.setDescription(getI18nProvider().getMessage("categories.add.descr"));
        addButton.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                actionAdd();
            }
        });
        toolbar.addComponent(addButton);

        /*
         * Button: Edit the selected category
         */
        editButton = new Button();
        editButton.setIcon(new ThemeResource("icons/16/pencil.png"));
        editButton.setStyleName("small");
        editButton.setDescription(getI18nProvider().getMessage("categories.edit.descr"));
        editButton.setEnabled(false);
        editButton.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                actionEdit();
            }
        });
        toolbar.addComponent(editButton);

        /*
         * Button: Delete the selected category
         */
        deleteButton = new Button();
        deleteButton.setIcon(new ThemeResource("icons/16/delete.png"));
        deleteButton.setStyleName("small");
        deleteButton.setDescription(getI18nProvider().getMessage("categories.delete.descr"));
        deleteButton.setEnabled(false);
        deleteButton.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                actionDelete();
            }
        });
        toolbar.addComponent(deleteButton);

        /*
         * Button: Show/edit the access control list for the selected
         * category
         */
        aclButton = new Button();
        aclButton.setIcon(new ThemeResource("icons/16/lock_edit.png"));
        aclButton.setStyleName("small");
        aclButton.setDescription(getI18nProvider().getMessage("categories.acl.descr"));
        aclButton.setEnabled(false);
        aclButton.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                actionACL();
            }
        });
        toolbar.addComponent(aclButton);

        /*
         * Button: Show the audit log for the selected category
         */
        auditButton = new Button();
        auditButton.setIcon(new ThemeResource("icons/16/key.png"));
        auditButton.setStyleName("small");
        auditButton.setDescription(getI18nProvider().getMessage("categories.audit.descr"));
        auditButton.setEnabled(false);
        auditButton.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                actionAudit();
            }
        });
        toolbar.addComponent(auditButton);
    }

    /*
     * The browser layout contains the category tree and the toolbar.
     */
    browserComponent = new VerticalLayout();
    browserComponent.setSizeFull();
    browserComponent.addComponent(categoryTree);
    browserComponent.addComponent(categoryForm.getComponent());
    browserComponent.addComponent(toolbar);
    browserComponent.setExpandRatio(categoryTree, 1.0f);
    browserComponent.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER);

    /*
     * Register a listener that updates the enablement state every time the
     * selection changes.
     */
    categoryTree.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            updateEnablementState();
            Long newCategoryId = (Long) event.getProperty().getValue();
            Category newCategory = null;
            if (newCategoryId != null) {
                BeanItem<Category> item = categoryContainer.getItem(newCategoryId);
                if (item != null) {
                    newCategory = item.getBean();
                }
            }
            fireCategorySelectionChanged(newCategory);
        }
    });
}

From source file:com.github.peholmst.springsecuritydemo.ui.MainView.java

License:Apache License

protected void init() {
    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();/*from  w w  w  .  j  av  a2 s. co m*/

    /*
     * The header is shown on top of the window and shows information about
     * the application and the current user.
     */
    final Component header = createHeader();
    mainLayout.addComponent(header);

    /*
     * The split panel will contain the component that actually make the
     * application usable.
     */

    final SplitPanel splitPanel = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
    splitPanel.setSizeFull();
    mainLayout.addComponent(splitPanel);
    mainLayout.setExpandRatio(splitPanel, 1.0f);

    splitPanel.addComponent(categoryBrowser.getComponent());

    final Component ticketBrowser = createTicketBrowser();
    splitPanel.addComponent(ticketBrowser);

    splitPanel.setSplitPosition(25, Sizeable.UNITS_PERCENTAGE);

    setCompositionRoot(mainLayout);
}

From source file:com.github.peholmst.springsecuritydemo.ui.MainView.java

License:Apache License

/**
 * TODO Document me!/* ww w.  jav  a  2s .c o m*/
 * 
 * @return
 */
protected Component createTicketBrowser() {
    final HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.setSpacing(true);
    toolbar.setWidth("100%");

    final Button refreshButton = new Button(getApplication().getMessage("tickets.refresh.caption"));
    refreshButton.setIcon(new ThemeResource("icons/16/refresh.png"));
    refreshButton.setStyleName("small");
    refreshButton.setDescription(getApplication().getMessage("tickets.refresh.descr"));
    toolbar.addComponent(refreshButton);
    toolbar.setComponentAlignment(refreshButton, Alignment.MIDDLE_LEFT);

    final Button addButton = new Button(getApplication().getMessage("tickets.add.caption"));
    addButton.setIcon(new ThemeResource("icons/16/add.png"));
    addButton.setStyleName("small");
    addButton.setDescription(getApplication().getMessage("tickets.add.descr"));
    toolbar.addComponent(addButton);
    toolbar.setComponentAlignment(addButton, Alignment.MIDDLE_RIGHT);

    final SplitPanel splitPanel = new SplitPanel();
    splitPanel.setSizeFull();

    final Table ticketsTable = new Table();
    ticketsTable.setSizeFull();
    splitPanel.addComponent(ticketsTable);

    splitPanel.addComponent(new Label("The form for editing tickets will show up here"));

    final VerticalLayout browser = new VerticalLayout();
    browser.setSizeFull();
    browser.addComponent(toolbar);
    browser.addComponent(splitPanel);
    browser.setExpandRatio(splitPanel, 1.0f);

    return browser;
}

From source file:com.github.tempora.view.MainView.java

License:Apache License

public MainView() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.addStyleName("outlined");
    vlayout.addStyleName("bg");
    vlayout.setSizeFull();/*from w ww . java  2s . co m*/
    vlayout.setMargin(true);
    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.addStyleName("outlined");
    hlayout.setSizeFull();
    setContent(vlayout);

    // Title
    Label caption = new Label("Tempora");
    caption.setStyleName("logo-label", true);
    caption.setWidth(null);
    vlayout.addComponent(caption);
    vlayout.setExpandRatio(caption, 0.2f);

    vlayout.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    vlayout.addComponent(hlayout);
    vlayout.setExpandRatio(hlayout, 0.7f);

    //
    // General information about the User's mailbox
    //
    final Panel generalInfoPanel = new Panel("<center>General Information</center>");
    generalInfoPanel.addStyleName("frame-bg-general-info");
    generalInfoPanel.setSizeFull();

    this.currentHistoryId = new Label("0");
    currentHistoryId.setStyleName("general-info-count", true);
    currentHistoryId.setCaption("History ID");

    this.messagesTotal = new Label("0");
    messagesTotal.setStyleName("general-info-count", true);
    messagesTotal.setCaption("Messages Total");

    this.threadsTotal = new Label("0");
    threadsTotal.setCaption("Threads Total");
    threadsTotal.setStyleName("general-info-count", true);

    FormLayout mailboxInfoLayout = new FormLayout(messagesTotal, currentHistoryId, threadsTotal);
    VerticalLayout mailboxInfoMainLayout = new VerticalLayout(mailboxInfoLayout);
    mailboxInfoMainLayout.setSizeFull();
    mailboxInfoMainLayout.setMargin(true);
    generalInfoPanel.setContent(mailboxInfoMainLayout);

    //
    // Stats
    //
    final Panel statsPanel = new Panel("<center>Statistics</center>");
    statsPanel.addStyleName("frame-bg-stats");
    statsPanel.setSizeFull();

    this.bodyAvgSize = new Label("0");
    bodyAvgSize.setCaption("Body Avg. Size");
    bodyAvgSize.setStyleName("stats-count", true);

    FormLayout statsLayout = new FormLayout(bodyAvgSize);
    VerticalLayout statsMainLayout = new VerticalLayout(statsLayout);
    statsMainLayout.setSizeFull();
    statsMainLayout.setMargin(true);
    statsPanel.setContent(statsMainLayout);

    //
    // Top 5
    //
    Panel top5Panel = new Panel("<center>Top 5</center>");
    top5Panel.addStyleName("frame-bg-top5");

    // Top 5 Senders
    Panel top5SendersPanel = new Panel("<center>Senders</center>");
    top5SendersPanel.addStyleName("frame-bg-top5");
    top5SendersPanel.setSizeFull();
    this.top5Senders = new Label("NO DATA", ContentMode.PREFORMATTED);
    top5Senders.setSizeUndefined();
    top5SendersPanel.setContent(top5Senders);

    // Top 5 Title Tags
    Panel top5TitleTagsPanel = new Panel("<center>Title Tags</center>");
    top5TitleTagsPanel.addStyleName("frame-bg-top5");
    top5TitleTagsPanel.setSizeFull();
    this.top5TitleTags = new Label("NO DATA", ContentMode.PREFORMATTED);
    top5TitleTags.setSizeUndefined();
    top5TitleTagsPanel.setContent(top5TitleTags);

    top5Panel.setSizeFull();

    VerticalLayout top5MainLayout = new VerticalLayout(top5SendersPanel, top5TitleTagsPanel);
    top5MainLayout.setMargin(true);
    top5MainLayout.setSpacing(true);
    top5MainLayout.setSizeFull();
    top5MainLayout.setComponentAlignment(top5SendersPanel, Alignment.MIDDLE_CENTER);
    top5MainLayout.setComponentAlignment(top5TitleTagsPanel, Alignment.MIDDLE_CENTER);
    top5Panel.setContent(top5MainLayout);

    hlayout.setSpacing(true);
    hlayout.addComponent(generalInfoPanel);
    hlayout.addComponent(statsPanel);
    hlayout.addComponent(top5Panel);

    this.currentUserEmail = new Label("-");
    currentUserEmail.setCaption("Email");

    Button reloadButton = new Button("\u27F3 Reload");
    reloadButton.addClickListener(e -> {
        getSession().getSession().invalidate();
        getUI().getPage().reload();
    });

    HorizontalLayout infoHLayout = new HorizontalLayout();
    infoHLayout.addStyleName("outlined");
    infoHLayout.setSizeFull();
    infoHLayout.setSpacing(true);
    infoHLayout.setMargin(true);

    infoHLayout.addComponent(reloadButton);
    reloadButton.setWidth(null);
    infoHLayout.setComponentAlignment(reloadButton, Alignment.BOTTOM_LEFT);

    infoHLayout.addComponent(currentUserEmail);
    currentUserEmail.setWidth(null);
    infoHLayout.setComponentAlignment(currentUserEmail, Alignment.BOTTOM_RIGHT);

    vlayout.addComponent(infoHLayout);
    vlayout.setExpandRatio(infoHLayout, 0.5f);
}

From source file:com.github.wolfie.detachedtabs.DetachedTabs.java

License:Open Source License

private DetachedTabs(final ComponentContainer componentContainer, final Orientation orientation) {

    if (componentContainer == null || orientation == null) {
        throw new NullPointerException("arguments may not be null");
    }// w  w w.j  a va2  s .co m

    setStyleName(CLASS);

    setSizeFull();

    switch (orientation) {
    case HORIZONTAL:
        layout = new HorizontalLayout();
        addStyleName(CLASS_HORIZONTAL);
        setHeight("30px");
        break;
    case VERTICAL:
        layout = new VerticalLayout();
        addStyleName(CLASS_VERTICAL);
        setWidth("100px");
        break;
    default:
        throw new UnsupportedOperationException("orientation " + orientation + " not supported");
    }

    layout.setSizeFull();

    setCompositionRoot(layout);
    this.componentContainer = componentContainer;
    this.orientation = orientation;
}