Example usage for com.google.gwt.widgetideas.client ProgressBar getMaxProgress

List of usage examples for com.google.gwt.widgetideas.client ProgressBar getMaxProgress

Introduction

In this page you can find the example usage for com.google.gwt.widgetideas.client ProgressBar getMaxProgress.

Prototype

public double getMaxProgress() 

Source Link

Document

Get the maximum progress.

Usage

From source file:org.kuali.student.core.document.ui.client.widgets.documenttool.DocumentTool.java

License:Educational Community License

@Override
protected Widget createWidget() {
    //This section title code does not seem consistent with other sections (i.e: of CourseProposal)
    //  section title is now instead displayed based on verticalSectionView in createUploadForm()
    /*SectionTitle viewTitle = SectionTitle.generateH2Title(getTitle());
              //from ww  w.  ja va  2 s.  c o  m
    viewTitle.addStyleName("ks-layout-header");
    layout.add(viewTitle);*/

    layout.add(saveWarning);
    saveWarning.setVisible(false);
    buttonPanel.setButtonText(OkEnum.Ok, "Upload");
    buttonPanel.getButton(OkEnum.Ok).setStyleName(ButtonStyle.SECONDARY.getStyle());

    uploadList.add(createUploadForm());
    form.setWidget(uploadList);
    form.setMethod(FormPanel.METHOD_POST);
    form.setEncoding(FormPanel.ENCODING_MULTIPART);

    buttonPanel.setContent(form);
    if (showAllLink != null) {
        layout.add(showAllLink);
    }
    layout.add(buttonPanel);
    layout.add(documentList);
    documentList.setVisible(false);
    buttonPanel.setVisible(false);

    SectionTitle sectionTitle = SectionTitle.generateH2Title("Upload Status");
    progressWindow.setNonCaptionHeader(sectionTitle);
    progressPanel.add(progressLabel);
    progressPanel.add(progressBar);
    progressPanel.add(fileProgressTable);
    progressBar.setWidth("400px");
    progressBar.setTextFormatter(new TextFormatter() {

        @Override
        protected String getText(ProgressBar bar, double curProgress) {
            String result;
            NumberFormat nf = NumberFormat.getFormat("#.##");
            if (curProgress == bar.getMaxProgress()) {
                result = "Total Uploaded: " + nf.format(curProgress) + "kb";
            } else if (curProgress == 0 || bar.getMaxProgress() == 0) {
                result = "";
            } else {
                String curProgressString;
                String maxProgressString;

                if (curProgress < 1024) {
                    curProgressString = nf.format(curProgress) + "kb";
                } else {
                    curProgressString = nf.format(curProgress / 1024) + "mb";
                }

                if (bar.getMaxProgress() < 1024) {
                    maxProgressString = nf.format(bar.getMaxProgress()) + "kb";
                } else {
                    maxProgressString = nf.format((bar.getMaxProgress()) / 1024) + "mb";
                }
                result = curProgressString + " out of " + maxProgressString;
            }
            return result;
        }
    });
    progressBar.setHeight("30px");
    progressPanel.add(progressButtons);
    progressPanel.setWidth("500px");
    progressWindow.setWidget(progressPanel);
    progressWindow.setSize(520, 270);

    return layout;
}