Example usage for com.vaadin.ui HorizontalLayout setExpandRatio

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

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout 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:de.catma.ui.repository.wizard.IndexerOptionsPanel.java

License:Open Source License

private void initComponents() {
    setSpacing(true);/*  w  ww.ja  v  a  2  s  . c  o  m*/
    setSizeFull();

    Label infoLabel = new Label();

    infoLabel.setContentMode(Label.CONTENT_XHTML);
    infoLabel.setValue("<p>This section allows you to finetune the creation "
            + "of the word list of your Source Document.</p>"
            + "<p>If you are unsure what to do, just select the language "
            + "and leave everything else unmodified.</p>");
    addComponent(infoLabel, 0, 0, 2, 0);

    cbUseApostrophe = new CheckBox("always use the apostrophe as a word separator");

    addComponent(cbUseApostrophe, 0, 1, 2, 1);

    Locale[] all = Locale.getAvailableLocales();

    sortedLangs = new TreeSet<LanguageItem>();
    for (Locale locale : all) {
        sortedLangs.add(new LanguageItem(locale));
    }

    languagesListSelect = new ListSelect("Please select the predominant language of the Source Document:",
            sortedLangs);
    languagesListSelect.setNullSelectionAllowed(false);
    languagesListSelect.setSizeFull();
    languagesListSelect.setImmediate(true);

    addComponent(languagesListSelect, 0, 2, 0, 3);

    unseparableCharacterSequencesListSelect = new ListSelect("Unseparable character sequences:");
    unseparableCharacterSequencesListSelect.setNullSelectionAllowed(false);
    unseparableCharacterSequencesListSelect.setSizeFull();
    unseparableCharacterSequencesListSelect.setImmediate(true);

    addComponent(unseparableCharacterSequencesListSelect, 1, 2, 1, 3);

    HorizontalLayout ucsAddRemoveLayout = new HorizontalLayout();
    Panel ucsAddRemovePanel = new Panel(ucsAddRemoveLayout);
    ucsAddRemovePanel.setStyleName(Reindeer.PANEL_LIGHT);
    ucsAddRemoveLayout.setSpacing(true);
    ucsAddRemoveLayout.setSizeFull();

    btAddUcs = new Button("Add entry");
    btAddUcs.setEnabled(false);
    ucsAddRemovePanel.addComponent(btAddUcs);
    tfUcs = new TextField();
    tfUcs.setInputPrompt("Add things like 'e.g.' as you see fit.");
    tfUcs.setImmediate(true);
    tfUcs.setTextChangeEventMode(TextChangeEventMode.EAGER);
    tfUcs.setWidth("100%");

    ucsAddRemovePanel.addComponent(tfUcs);
    ucsAddRemoveLayout.setExpandRatio(tfUcs, 2);
    btRemoveUcs = new Button("Remove entry");
    btRemoveUcs.setEnabled(false);
    ucsAddRemovePanel.addComponent(btRemoveUcs);

    addComponent(ucsAddRemovePanel, 1, 4);

    VerticalLayout loadSavePanel = new VerticalLayout();
    loadSavePanel.setSpacing(true);
    loadSavePanel.setWidth("80px");

    btLoadUcsList = new Button("Load list");
    loadSavePanel.addComponent(btLoadUcsList);
    btSaveUcsList = new Button("Save list");
    loadSavePanel.addComponent(btSaveUcsList);

    addComponent(loadSavePanel, 2, 2);

    setColumnExpandRatio(0, 2);
    setColumnExpandRatio(1, 2);

    setRowExpandRatio(2, 2);
    setRowExpandRatio(3, 2);
}

From source file:de.catma.ui.repository.wizard.LocationPanel.java

License:Open Source License

private void initComponents() {
    setSpacing(true);/*from w w  w.  j  av  a2 s .c  o m*/
    setMargin(true, false, false, false);

    setSizeFull();
    HorizontalLayout remoteLayout = new HorizontalLayout();
    remoteLayout.setMargin(true);
    remoteLayout.setSpacing(true);
    remoteLayout.setSizeFull();

    remoteURIInputPanel = new Panel(remoteLayout);

    remoteURIInput = new TextField();
    remoteURIInput.setCaption("Enter an URI that is accessible over the internet:");
    remoteURIInput.setWidth("100%");
    remoteURIInput.setTextChangeEventMode(TextChangeEventMode.EAGER);
    remoteURIInputPanel.addComponent(remoteURIInput);
    remoteLayout.setExpandRatio(remoteURIInput, 2);

    addComponent(remoteURIInputPanel);

    Label localFileLabel = new Label("or upload a local file from your computer:");
    addComponent(localFileLabel);

    uploadPanel = new UploadPanel();

    addComponent(uploadPanel);
}

From source file:de.datenhahn.vaadin.componentrenderer.demo.StaticCustomerDetailsGenerator.java

License:Apache License

@Override
public Component getDetails(Grid.RowReference rowReference) {
    rowReference.getGrid().scrollTo(rowReference.getItemId());
    StaticCustomer customer = (StaticCustomer) rowReference.getItemId();

    HorizontalLayout layout = new HorizontalLayout();
    layout.setHeight(300, Sizeable.Unit.PIXELS);
    layout.setMargin(true);/*from  ww  w .j a v a2s  .  c o m*/
    layout.setSpacing(true);
    Image image = new Image("", customer.getPhoto());
    image.setHeight(200, Sizeable.Unit.PIXELS);
    image.setWidth(200, Sizeable.Unit.PIXELS);
    layout.addComponent(image);
    Label nameLabel = new Label("<h1>" + customer.getFirstName() + " " + customer.getLastName() + "</h1>",
            ContentMode.HTML);
    layout.addComponent(nameLabel);
    layout.setExpandRatio(nameLabel, 1.0f);
    return layout;
}

From source file:de.escidoc.admintool.view.EscidocPagedTable.java

License:Open Source License

public HorizontalLayout createControls() {
    // final Label itemsPerPageLabel = new Label("Items per page:");
    final Label pageLabel = new Label("Page:&nbsp;", Label.CONTENT_XHTML);
    final TextField currentPageTextField = new TextField();
    currentPageTextField.setValue(String.valueOf(getCurrentPage()));
    currentPageTextField.addValidator(new IntegerValidator(null));
    final Label separatorLabel = new Label("&nbsp;/&nbsp;", Label.CONTENT_XHTML);
    final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), Label.CONTENT_XHTML);
    currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL);
    currentPageTextField.setImmediate(true);
    currentPageTextField.addListener(new ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        public void valueChange(final com.vaadin.data.Property.ValueChangeEvent event) {
            if (currentPageTextField.isValid() && currentPageTextField.getValue() != null) {
                @SuppressWarnings("boxing")
                final int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue()));
                setCurrentPage(page);/*  ww  w. j a va 2 s . c  o  m*/
            }
        }
    });
    pageLabel.setWidth(null);
    currentPageTextField.setWidth("20px");
    separatorLabel.setWidth(null);
    totalPagesLabel.setWidth(null);

    final HorizontalLayout controlBar = new HorizontalLayout();
    final HorizontalLayout pageSize = new HorizontalLayout();
    final HorizontalLayout pageManagement = new HorizontalLayout();
    final Button first = new Button("<<", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            setCurrentPage(0);
        }
    });
    final Button previous = new Button("<", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            previousPage();
        }
    });
    final Button next = new Button(">", new ClickListener() {
        private static final long serialVersionUID = -1927138212640638452L;

        public void buttonClick(final ClickEvent event) {
            nextPage();
        }
    });
    final Button last = new Button(">>", new ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        public void buttonClick(final ClickEvent event) {
            setCurrentPage(getTotalAmountOfPages());
        }
    });
    first.setStyleName(BaseTheme.BUTTON_LINK);
    previous.setStyleName(BaseTheme.BUTTON_LINK);
    next.setStyleName(BaseTheme.BUTTON_LINK);
    last.setStyleName(BaseTheme.BUTTON_LINK);

    pageLabel.addStyleName("pagedtable-pagecaption");
    currentPageTextField.addStyleName("pagedtable-pagefield");
    separatorLabel.addStyleName("pagedtable-separator");
    totalPagesLabel.addStyleName("pagedtable-total");
    first.addStyleName("pagedtable-first");
    previous.addStyleName("pagedtable-previous");
    next.addStyleName("pagedtable-next");
    last.addStyleName("pagedtable-last");

    pageLabel.addStyleName("pagedtable-label");
    currentPageTextField.addStyleName("pagedtable-label");
    separatorLabel.addStyleName("pagedtable-label");
    totalPagesLabel.addStyleName("pagedtable-label");
    first.addStyleName("pagedtable-button");
    previous.addStyleName("pagedtable-button");
    next.addStyleName("pagedtable-button");
    last.addStyleName("pagedtable-button");

    pageSize.setSpacing(true);
    pageManagement.addComponent(first);
    pageManagement.addComponent(previous);
    pageManagement.addComponent(pageLabel);
    pageManagement.addComponent(currentPageTextField);
    pageManagement.addComponent(separatorLabel);
    pageManagement.addComponent(totalPagesLabel);
    pageManagement.addComponent(next);
    pageManagement.addComponent(last);
    pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT);
    pageManagement.setWidth(null);
    pageManagement.setSpacing(true);
    controlBar.addComponent(pageSize);
    controlBar.addComponent(pageManagement);
    controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER);
    controlBar.setWidth("100%");
    controlBar.setExpandRatio(pageSize, 1);
    addListener(new PageChangeListener() {
        @SuppressWarnings("boxing")
        public void pageChanged(final PagedTableChangeEvent event) {
            previous.setEnabled(true);
            next.setEnabled(true);
            currentPageTextField.setValue(String.valueOf(getCurrentPage()));
            totalPagesLabel.setValue(getTotalAmountOfPages());
        }
    });
    return controlBar;
}

From source file:de.fatalix.bookery.view.admin.AppUserCard.java

License:Open Source License

private HorizontalLayout createHeader() {
    captionLabel = new Label("some.user");
    Button deleteUser = new Button(null, new Button.ClickListener() {

        @Override/*w w w.ja  va 2s  . c om*/
        public void buttonClick(Button.ClickEvent event) {
            presenter.deleteUser(appUser);
            for (Listener listener : listeners) {
                listener.userDeleted(AppUserCard.this);
            }
        }
    });
    deleteUser.setIcon(FontAwesome.TIMES_CIRCLE);
    deleteUser.addStyleName("borderless");
    deleteUser.addStyleName("icon-only");

    HorizontalLayout captionLayout = new HorizontalLayout();
    captionLayout.addStyleName("v-panel-caption");
    captionLayout.setWidth("100%");
    captionLayout.addComponents(captionLabel, deleteUser);
    captionLayout.setExpandRatio(captionLabel, 1);

    return captionLayout;
}

From source file:de.fatalix.bookery.view.admin.BatchJobCard.java

private HorizontalLayout createHeader() {
    captionLabel = new Label("some.batchjob");

    Button deleteBatchJob = new Button(null, new Button.ClickListener() {

        @Override/*from   ww w . jav a  2  s  .  c  o m*/
        public void buttonClick(Button.ClickEvent event) {
            presenter.deleteBatchJob(jobConfig);
            for (BatchJobCard.Listener listener : listeners) {
                listener.jobDeleted(BatchJobCard.this);
            }
        }
    });
    deleteBatchJob.setIcon(FontAwesome.TIMES_CIRCLE);
    deleteBatchJob.addStyleName("borderless");
    deleteBatchJob.addStyleName("icon-only");

    HorizontalLayout captionLayout = new HorizontalLayout();
    captionLayout.addStyleName("v-panel-caption");
    captionLayout.setWidth("100%");
    captionLayout.addComponents(captionLabel, deleteBatchJob);
    captionLayout.setExpandRatio(captionLabel, 1);

    return captionLayout;
}

From source file:de.gedoplan.webclients.vaadin.views.CustomerDetailView.java

public void init() {
    Double discount = customerService.calculateCustomerDiscount(customer.getCustomerID()).getDiscount();
    Label name = new Label(new PropertyFormatter(form.getProperty(Customer_.companyName)) {
        @Override/*from  ww w .j a  v a  2s  . com*/
        public String format(Object value) {
            return value + " (" + customer.getCustomerID() + ")";
        }

        @Override
        public Object parse(String formattedValue) throws Exception {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    name.setStyleName(ValoTheme.LABEL_BOLD);
    Label rabattLabel = new Label(Messages.customer_discount.value());
    rabattLabel.setStyleName(ValoTheme.LABEL_BOLD);
    rabattLabel.setSizeUndefined();
    Label rabatt = new Label(new DecimalFormat("#0.00").format(discount) + "%");
    rabatt.setSizeUndefined();
    rabatt.addStyleName(ValoTheme.LABEL_COLORED);
    rabatt.addStyleName(ValoTheme.LABEL_BOLD);
    HorizontalLayout headline = new HorizontalLayout(name, rabattLabel, rabatt);
    headline.setComponentAlignment(rabatt, Alignment.TOP_RIGHT);
    headline.setExpandRatio(name, 1);
    headline.setWidth(100, Unit.PERCENTAGE);
    headline.setSpacing(true);
    headline.setStyleName(ValoTheme.LAYOUT_WELL);
    headline.setMargin(new MMarginInfo(false, true));
    Panel panel = new Panel();
    panel.setContent(form);
    setMargin(true);
    setSpacing(true);
    addComponents(headline, panel);
}

From source file:de.kaiserpfalzEdv.vaadin.PiraccUI.java

License:Apache License

protected void showMainView() {
    HorizontalLayout screen = new HorizontalLayout();

    CssLayout viewContainer = new CssLayout();
    viewContainer.addStyleName("valo-content");
    viewContainer.setSizeFull();//  w ww  . ja  v  a 2  s  .com

    screen.setStyleName("main-screen");
    screen.addComponent(menu);
    screen.addComponent(viewContainer);
    screen.setExpandRatio(viewContainer, 1);
    screen.setSizeFull();

    Navigator navigator = new Navigator(this, viewContainer);
    navigator.addProvider(viewProvider);

    addStyleName(ValoTheme.UI_WITH_MENU);
    setContent(screen);

    if (isNotBlank(getNavigator().getState())) {
        getNavigator().navigateTo(getNavigator().getState());
    }

    menu.generate();
}

From source file:de.mendelson.comm.as2.webclient2.AS2WebUI.java

private HorizontalLayout createButtonBar() {
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSizeFull();// w ww .j  a  v  a2s  . com
    Button buttonRefresh = new Button("Refresh");
    buttonRefresh.setIcon(new ThemeResource("images/refresh16x16.gif"));
    buttonRefresh.setEnabled(true);
    buttonRefresh.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            AS2WebUI.this.refreshOverviewTableData();
        }
    });
    buttonLayout.addComponent(buttonRefresh);
    this.buttonDetails = new Button("Message details");
    this.buttonDetails.setIcon(new ThemeResource("images/messagedetails16x16.gif"));
    this.buttonDetails.setEnabled(false);
    this.buttonDetails.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            AS2WebUI.this.displayMessageDetailsOfSelectedRow();
        }
    });
    buttonLayout.addComponent(this.buttonDetails);
    this.labelUsername.setWidth(null);
    buttonLayout.addComponent(this.labelUsername);
    buttonLayout.setComponentAlignment(this.labelUsername, Alignment.MIDDLE_RIGHT);
    buttonLayout.setExpandRatio(buttonRefresh, 0.0f);
    buttonLayout.setExpandRatio(this.buttonDetails, 0.0f);
    buttonLayout.setExpandRatio(this.labelUsername, 1.0f);
    return (buttonLayout);
}

From source file:de.symeda.sormas.ui.caze.AbstractTableField.java

License:Open Source License

@Override
protected Component initContent() {

    this.addStyleName(CssStyles.CAPTION_HIDDEN);
    this.addStyleName(CssStyles.VSPACE_2);

    layout = new VerticalLayout();
    layout.setSpacing(false);/*from  w  ww.j  av  a 2  s .  c  om*/

    HorizontalLayout headerLayout = new HorizontalLayout();
    {
        headerLayout.setWidth(100, Unit.PERCENTAGE);

        captionLabel = new Label(getCaption());
        captionLabel.setSizeUndefined();
        headerLayout.addComponent(captionLabel);
        headerLayout.setComponentAlignment(captionLabel, Alignment.BOTTOM_LEFT);
        headerLayout.setExpandRatio(captionLabel, 0);

        addButton = createAddButton();
        headerLayout.addComponent(addButton);
        headerLayout.setComponentAlignment(addButton, Alignment.BOTTOM_RIGHT);
        headerLayout.setExpandRatio(addButton, 1);
    }
    layout.addComponent(headerLayout);

    table = createTable();
    table.addItemSetChangeListener(new ItemSetChangeListener() {
        @Override
        public void containerItemSetChange(ItemSetChangeEvent event) {
            applyTablePageLength();
        }
    });
    layout.addComponent(table);

    return layout;
}