[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Re: .035 'Next' Action in a wizard page

Ilya Rozenberg wrote:

> I would like to start a time consuming operation on the "Next" button
> click event with involves IProgressMonitor and then show next page.

Have you tried something like:

public boolean canFlipToNextPage() {
        return isPageComplete();
}
public IWizardPage getNextPage() {
        IRunnableWithProgress op = new IRunnableWithProgress() {
                public void run(IProgressMonitor progress) {
                        progress.beginTask("Performing operation ", 100);
                        for (int i = 0; i < 100; i++) {
                                if (progress.isCanceled())
                                        throw new 
OperationCanceledException();
                                progress.worked(1);
                                try {
                                        Thread.sleep(20);
                                } catch (InterruptedException ex) {
                                }
                        }
                        progress.done();
                }
        };
        try {
                getContainer().run(true, true, op);
        } catch (InvocationTargetException e) {
                return this;
        } catch (InterruptedException e) {
                return this;
        }
        return super.getNextPage();
}