Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I correctly update a progress bar for an operation of unknown duration within an Eclipse wizard?
    text
    copied!<p>I have implemented a wizard for my Eclipse plug-in, showing several pages. One of these pages needs some lengthy initialization, that means it consists of a SWT table, which needs to be populated by information coming from an external source. This source needs to be activated first (one single method call that returns after a couple of seconds - I can not know in advance how long it will take exactly), before it can be used as input for for the table viewer. This initialization is currently done by the table model provider when it needs to access the external source for the first time.</p> <p>Therefore, when I enter the wizard page, I would like to show a dummy progress bar that just counts up for a while. My approach was the following, but unfortunately does not work at all:</p> <pre><code>private void initViewer() { IRunnableWithProgress runnable = new IRunnableWithProgress() { // needed to embed long running operation into the wizard page @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { SubMonitor progress = SubMonitor.convert(monitor); Thread thread = new Thread() { @Override public void run() { Display.getDefault().syncExec(new Runnable() { public void run() { viewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); // this will make the table provider initialize the external source. } }); } }; thread.start(); while(thread.isAlive()) { progress.setWorkRemaining(10000); progress.worked(1); } progress.done(); } }; try { getContainer().run(false, false, runnable); } catch(Exception e) { throw new Exception("Could not access data store", e); } } </code></pre> <p>This method gets then invoked when the wizard page's setVisible()-method is called and should, after a couple of seconds, set the viewer's input. This, however, never happens, because the inner-most run()-method never gets executed.</p> <p>Any hints on how to deal with long-running (where an exact estimate is not available) initializations in Eclipse wizards would be very appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload