Forum Discussion

thedivxboy's avatar
thedivxboy
Occasional Contributor
17 years ago

ProgressDialog

Hi,

I tried quite everything in the SoapUI API for progress bars and dialogs .. without results. I've also tried several samples found on google during three hours, but no examples are related to SoapUI.

When I execute this simple groovy script the progress dialog never progress and doesn't disappear (even if I put the parameter allowCancel of the constructor ProgressDialog to true like in the example).

delayBeforeReply = 3000;
msg = "Waiting " + delayBeforeReply + " ms before processing the reply part.";
progressBar = new com.eviware.soapui.support.components.ProgressDialog("Wait", msg, delayBeforeReply, "0", true);
progressBar.setVisible(true);

for (int i=0;i<=delayBeforeReply;i++) {
    Thread.sleep(1);
    progressBar.setProgress(i, ""+i);
}

progressBar.setVisible(false);
progressBar.dispose();



Do you have any solution ? What's wrong with my code ?

Kind regards,
Arnaud.

2 Replies

  • thedivxboy's avatar
    thedivxboy
    Occasional Contributor
    Hi all,

    After a lot of time spent to find a solution I've tested successfully the following code in Eclipse:

    package soapui.testStep;

    import com.eviware.soapui.support.components.ProgressDialog;

    public class progressBar {
        public static void main(String[] args) {
            final Integer delayBeforeReply  = 5000;
            String msg                      = "Waiting " + delayBeforeReply + " ms before processing the reply part.";
            final ProgressDialog progressBar = new ProgressDialog("Wait", msg, delayBeforeReply, "0", false);

            Runnable r = new Runnable() {
                public void run() {
                    for (int i=1;i<=delayBeforeReply/1000;i++) {
                        progressBar.setProgress(i, (delayBeforeReply/1000)-(i-1) + " second(s) remaining ...");

                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }

                    progressBar.dispose();
                }
            };

            new Thread(r).start();
            progressBar.setVisible(true);
        }
    }


    But when I adapt it to SoapUI with the groovy version, the progress bar never disappear ..

    Can someone help me ?

    Thanks in advance,
    Arnaud.
  • Hello!

    Try this script, it should get the job done. Modify the construct method as required.
    It can be canceled as well. Good luck!


    import com.eviware.soapui.support.UISupport;
    import com.eviware.x.dialogs.XProgressMonitor;
    import com.eviware.x.dialogs.Worker.WorkerAdapter;

    class MyWorker extends WorkerAdapter {
    Thread current;
    boolean running = true;

    Object construct(XProgressMonitor mon) {
    current = Thread.currentThread();
    for(int i=0; i<=5; i++) {
    mon.setProgress(i, ""+i);
    try {
    Thread.sleep(1000);
    } catch(InterruptedException e) {
    }
    if(!running) return null;
    }
    return null;
    }

    boolean onCancel() {
    running = false;
    if(current != null) current.interrupt();
    return true;
    }
    }

    def p = UISupport.getDialogs().createProgressDialog("label", 5, "init", true);
    p.run(new MyWorker());


    /Dain
    eviware support