org.openxdata.sharedlib.client.view.ProgressDialog.java Source code

Java tutorial

Introduction

Here is the source code for org.openxdata.sharedlib.client.view.ProgressDialog.java

Source

package org.openxdata.sharedlib.client.view;

import org.openxdata.sharedlib.client.locale.FormsConstants;
import org.openxdata.sharedlib.client.util.FormUtil;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;

/**
 * Used to show a progress window to the user for slow processing operations.
 * 
 *  www.openxdata.org - Licensed as written in license.txt and original sources of this file and its authors are found in sources.txt.
 *
 */
public class ProgressDialog extends DialogBox {

    private FormsConstants constants = GWT.create(FormsConstants.class);

    /** The label to show the progress or processing message. */
    private Label label = new Label(constants.processingMsg());

    /**
     * Creates a new instance of the progress dialog.
     */
    public ProgressDialog() {
        super(false, true);

        HorizontalPanel panel = new HorizontalPanel();
        panel.add(FormUtil.createImage(FormRunnerView.images.loading()));
        panel.add(label);

        setWidget(panel);
    }

    /**
     * Displays the progress dialog box at the center of the browser window
     * with the default progress message which is "Please wait while processing..."
     */
    public void center() {

        //Reset the progress message to the default because it may have been
        //been changed with a custom one.
        label.setText(constants.processingMsg());

        super.center();
    }

    /**
     * Displays the progress dialog box at the center of the browser window
     * and with a custom progress message.
     * 
     * @param progressMsg the custom progress message.
     */
    public void center(String progressMsg) {
        if (progressMsg == null)
            center();
        else
            label.setText(progressMsg);
    }
}