Search code examples
javaeclipse-pluginprogress-barjobswizard

How do i implement a progress bar in the main wizard page with eclipse plugin?


i have an eclipse plugin app.I have implemented a new maven like wizard that is attached to the existing Eclipse wizard using the method addPages, and i didn't do any changes to the main wizard.When i am on the main wizard and click "Create new maven like project" it's doesn't load my wizard very quick (there is a method inside my wizard page that slows down the opening) so i want to implement a progress bar in the main wizard that traces the progress of opening my wizard, how can i do that?


Solution

  • Wizards have a built in progress bar which is normally used when clicking on Finish or moving between pages. You may be able to use this during the creation of your wizard.

    In the constructor of your wizard call:

    setNeedsProgressMonitor(true);
    

    To run your slow code use

    try
     {
       getContainer().run(true, true, runnableWithProgress);
     }
    catch (final InvocationTargetException ex)
     {
       // TODO handle
     }
    catch (final InterruptedException ex)
     {
       // TODO handle
     }
    

    where runnableWithProgress is something that implements IRunnableWithProgress and runs your slow code using the IProgressMonitor passed to the run method to update the progress bar.