Example usage for com.vaadin.v7.ui ProgressBar ProgressBar

List of usage examples for com.vaadin.v7.ui ProgressBar ProgressBar

Introduction

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

Prototype

public ProgressBar(Property<?> dataSource) 

Source Link

Document

Creates a new progress bar bound to the given data source.

Usage

From source file:de.symeda.sormas.ui.importer.ImportProgressLayout.java

License:Open Source License

public ImportProgressLayout(int totalCount, UI currentUI, Runnable cancelCallback) {
    this.totalCount = totalCount;
    this.currentUI = currentUI;

    setWidth(100, Unit.PERCENTAGE);//from w  w w .  j av  a  2 s.c  om
    setMargin(true);

    // Info text and icon/progress circle
    infoLayout = new HorizontalLayout();
    infoLayout.setWidth(100, Unit.PERCENTAGE);
    infoLayout.setSpacing(true);
    initializeInfoComponents();
    currentInfoComponent = progressCircle;
    infoLayout.addComponent(currentInfoComponent);
    infoLabel = new Label(String.format(I18nProperties.getString(Strings.infoImportProcess), totalCount));
    infoLabel.setContentMode(ContentMode.HTML);
    infoLayout.addComponent(infoLabel);
    infoLayout.setExpandRatio(infoLabel, 1);

    addComponent(infoLayout);

    // Progress bar
    progressBar = new ProgressBar(0.0f);
    CssStyles.style(progressBar, CssStyles.VSPACE_TOP_3);
    addComponent(progressBar);
    progressBar.setWidth(100, Unit.PERCENTAGE);

    // Progress info
    HorizontalLayout progressInfoLayout = new HorizontalLayout();
    CssStyles.style(progressInfoLayout, CssStyles.VSPACE_TOP_5);
    progressInfoLayout.setSpacing(true);
    processedImportsLabel = new Label(
            String.format(I18nProperties.getCaption(Captions.importProcessed), 0, totalCount));
    progressInfoLayout.addComponent(processedImportsLabel);
    successfulImportsLabel = new Label(String.format(I18nProperties.getCaption(Captions.importImports), 0));
    CssStyles.style(successfulImportsLabel, CssStyles.LABEL_POSITIVE);
    progressInfoLayout.addComponent(successfulImportsLabel);
    importErrorsLabel = new Label(String.format(I18nProperties.getCaption(Captions.importErrors), 0));
    CssStyles.style(importErrorsLabel, CssStyles.LABEL_CRITICAL);
    progressInfoLayout.addComponent(importErrorsLabel);
    importDuplicatesLabel = new Label(String.format(I18nProperties.getCaption(Captions.importDuplicates), 0));
    CssStyles.style(importDuplicatesLabel, CssStyles.LABEL_WARNING);
    progressInfoLayout.addComponent(importDuplicatesLabel);
    importSkipsLabel = new Label(String.format(I18nProperties.getCaption(Captions.importSkips), 0));
    CssStyles.style(importSkipsLabel, CssStyles.LABEL_MINOR);
    progressInfoLayout.addComponent(importSkipsLabel);
    addComponent(progressInfoLayout);
    setComponentAlignment(progressInfoLayout, Alignment.TOP_RIGHT);

    // Cancel button
    closeCancelButton = new Button(I18nProperties.getCaption(Captions.actionCancel));
    CssStyles.style(closeCancelButton, CssStyles.VSPACE_TOP_2);
    cancelListener = e -> {
        cancelCallback.run();
    };
    closeCancelButton.addClickListener(cancelListener);
    addComponent(closeCancelButton);
    setComponentAlignment(closeCancelButton, Alignment.MIDDLE_RIGHT);
}