Example usage for com.vaadin.ui VerticalLayout setExpandRatio

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

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:com.github.mjvesa.herd.HerdIDE.java

License:Apache License

private Component constructFilesTab() {
    VerticalLayout vl = new VerticalLayout();
    vl.setSpacing(true);/*w  w  w . jav a2s.  c om*/
    vl.setSizeFull();
    vl.addComponent(constructFileNameAndSaveButton());
    fileSelect = createFileSelect();
    vl.addComponent(fileSelect);
    vl.setExpandRatio(fileSelect, 1);
    return vl;
}

From source file:com.github.mjvesa.herd.HerdIDE.java

License:Apache License

private Component constructOutputTab() {
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();/*  w  w w.jav a2s.co m*/
    vl.addComponent(createLayoutClearButton());
    mainPanel = createMainPanel();
    vl.addComponent(mainPanel);
    vl.setExpandRatio(mainPanel, 1);
    return vl;
}

From source file:com.github.mjvesa.herd.HerdIDE.java

License:Apache License

private Component constructEditorTab() {
    VerticalLayout vl = new VerticalLayout();
    vl.setSpacing(true);//from   www .j a v  a2 s .c o  m
    vl.setSizeFull();
    editor = createEditor();
    vl.addComponent(editor);
    vl.setExpandRatio(editor, 1);
    vl.addComponent(constructButtons());
    return 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);/*from  w  w w .j  a v  a  2 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.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  om
    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.MainView.java

License:Apache License

protected void init() {
    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();/*from   w  ww.  j  a  va2  s  .com*/

    /*
     * 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!/*from ww w . j  a  va2 s. co 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();/*ww w.j a v  a2  s .  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.hack23.cia.web.impl.ui.application.views.admin.agentoperations.pagemode.AgentOperationsOverviewPageModContentFactoryImpl.java

License:Apache License

@Secured({ "ROLE_ADMIN" })
@Override//from   w  w  w.j  a va 2  s  . com
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout content = createPanelContent();

    getMenuItemFactory().createMainPageMenuBar(menuBar);

    LabelFactory.createHeader2Label(content, ADMIN_AGENT_OPERATION);

    final ComboBox targetSelect = new ComboBox(TARGET, Arrays.asList(DataAgentTarget.values()));
    targetSelect.setId(ViewAction.START_AGENT_BUTTON + TARGET2);
    content.addComponent(targetSelect);
    content.setExpandRatio(targetSelect, ContentRatio.SMALL2);

    final ComboBox operationSelect = new ComboBox(OPERATION, Arrays.asList(DataAgentOperation.values()));
    operationSelect.setId(ViewAction.START_AGENT_BUTTON + OPERATION2);
    content.addComponent(operationSelect);
    content.setExpandRatio(operationSelect, ContentRatio.SMALL2);

    final Button startAgentButton = new Button(START,
            new StartAgentClickListener(targetSelect, operationSelect, agentContainer));
    startAgentButton.setId(ViewAction.START_AGENT_BUTTON.name());
    startAgentButton.setIcon(FontAwesome.CROSSHAIRS);
    content.addComponent(startAgentButton);
    content.setExpandRatio(startAgentButton, ContentRatio.SMALL3);

    content.setSizeFull();
    content.setMargin(false);
    content.setSpacing(true);

    content.setWidth(100, Unit.PERCENTAGE);
    content.setHeight(100, Unit.PERCENTAGE);

    return content;
}

From source file:com.hack23.cia.web.impl.ui.application.views.admin.datasummary.pagemode.DataSummaryOverviewPageModContentFactoryImpl.java

License:Apache License

@Secured({ "ROLE_ADMIN" })
@Override//from  w  w  w  .  j a  va 2  s. co  m
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout content = createPanelContent();

    getMenuItemFactory().createMainPageMenuBar(menuBar);

    LabelFactory.createHeader2Label(content, ADMIN_DATA_SUMMARY);

    final Table createDataSummaryTable = tableFactory.createDataSummaryTable();
    content.addComponent(createDataSummaryTable);
    content.setExpandRatio(createDataSummaryTable, ContentRatio.LARGE);

    content.setSizeFull();
    content.setMargin(false);
    content.setSpacing(true);

    final Button refreshViewsButton = new Button(REFRESH_VIEWS, FontAwesome.REFRESH);

    refreshViewsButton.addClickListener(event -> {

        final RefreshDataViewsRequest serviceRequest = new RefreshDataViewsRequest();
        serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());

        getApplicationManager().asyncService(serviceRequest);
        Notification.show(REFRESH_VIEWS_STARTED);
    });

    content.addComponent(refreshViewsButton);
    content.setExpandRatio(refreshViewsButton, ContentRatio.SMALL);

    final Button updateSearchIndexButton = new Button(UPDATE_SEARCH_INDEX, FontAwesome.REFRESH);

    updateSearchIndexButton.addClickListener(event -> {

        final UpdateSearchIndexRequest serviceRequest = new UpdateSearchIndexRequest();
        serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());

        getApplicationManager().asyncService(serviceRequest);
        Notification.show(UPDATE_SEARCH_INDEX_STARTED);
    });

    content.addComponent(updateSearchIndexButton);
    content.setExpandRatio(updateSearchIndexButton, ContentRatio.SMALL);

    return content;

}