BusyIndicator vs ProgressMonitorDialog [message #331189] |
Wed, 27 August 2008 18:44 |
Paul E. Keyser Messages: 878 Registered: July 2009 |
Senior Member |
|
|
WinXP; R3.3
I seem to recall that there is already some way to get the following
behavior in Eclipse (but searching the help and these newsgroups turned
up no answer):
I have a long-running operation, which in some cases will complete in
(say) 1-2 sec, and in others will complete in more like 30-60 sec. It
has not yet proven possible to compute, in advance and reliably, how
long a given case will run.
So I would like to have the busy cursor appear, and then (if the
operation lasts longer than some time), to have the progress-monitor
dialog open.
I know how to do the first:
BusyIndicator.showWhile(someDisplay, someRunnable);
And the second looks like this:
try {
new ProgressMonitorDialog(someShell).run(false, false,
someRunnableWithProgress);
} catch (InvocationTargetException ite) {
logError(ite.getCause());
} catch (InterruptedException ie) {
; // since 'cancel' == false, this should never happen
}
Is there any built-in Eclipse way? Or is it a matter of my writing a
multithreaded timer, that monitors a Job, and then creates the
ProgressMonitorDialog on the fly if more than the specified time has
gone by?
thanks,
Paul
|
|
|
Re: BusyIndicator vs ProgressMonitorDialog [message #331191 is a reply to message #331189] |
Wed, 27 August 2008 18:54 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
PlatformUI.getWorkbench().getProgressService().
Tom
Paul Th. Keyser schrieb:
> WinXP; R3.3
>
> I seem to recall that there is already some way to get the following
> behavior in Eclipse (but searching the help and these newsgroups turned
> up no answer):
>
> I have a long-running operation, which in some cases will complete in
> (say) 1-2 sec, and in others will complete in more like 30-60 sec. It
> has not yet proven possible to compute, in advance and reliably, how
> long a given case will run.
>
> So I would like to have the busy cursor appear, and then (if the
> operation lasts longer than some time), to have the progress-monitor
> dialog open.
>
> I know how to do the first:
>
> BusyIndicator.showWhile(someDisplay, someRunnable);
>
> And the second looks like this:
>
> try {
> new ProgressMonitorDialog(someShell).run(false, false,
> someRunnableWithProgress);
>
> } catch (InvocationTargetException ite) {
> logError(ite.getCause());
>
> } catch (InterruptedException ie) {
> ; // since 'cancel' == false, this should never happen
> }
>
> Is there any built-in Eclipse way? Or is it a matter of my writing a
> multithreaded timer, that monitors a Job, and then creates the
> ProgressMonitorDialog on the fly if more than the specified time has
> gone by?
>
> thanks,
> Paul
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
|
|
|
Re: BusyIndicator vs ProgressMonitorDialog [message #331255 is a reply to message #331232] |
Thu, 28 August 2008 15:21 |
Eclipse User |
|
|
|
Originally posted by: mario.winterer.gmx.net
There seems to be something wrong in your code.
You wrote you are calling busyCursorWhile INSIDE your run method?
Your code should look like the following:
IRunnableWithProgress myRunnableWithProgress = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
monitor = (monitor == null) ? new NullProgressMonitor() : monitor;
try {
monitor.beginTask(...);
...
} finally {
monitor.done();
}
}
};
PlatformUI.getWorkbench().getProgressService().
busyCursorWhile(myRunnableWithProgress);
Paul Th. Keyser schrieb:
> Prakash G.R. wrote:
>> In your someRunnableWithProgress class, are you calling the
>> progressMonitor.beginTask() as soon as the run method is called?
>>
>>
>> - Prakash
>>
>
> Yep, the first lines of its run() method are:
>
> if (null != monitor) {
> String msg = ...;
> monitor.beginTask(msg, IProgressMonitor.UNKNOWN);
> }
>
> right after that the run() method has:
>
> try {
> PlatformUI.getWorkbench().getProgressService().
> busyCursorWhile(myRunnableWithProgress);
>
> } finally {
> if (null != monitor) {
> monitor.done();
> }
> }
>
> That is the same structure as I have when I use the simple
> ProgressMonitorDialog directly.
>
> (I have read the nice article
> http://www.eclipse.org/articles/Article-Progress-Monitors/ar ticle.html)
>
> -Paul
|
|
|
|
Powered by
FUDForum. Page generated in 0.03109 seconds