Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » BusyIndicator vs ProgressMonitorDialog
BusyIndicator vs ProgressMonitorDialog [message #331189] Wed, 27 August 2008 18:44 Go to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
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 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
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 #331193 is a reply to message #331191] Wed, 27 August 2008 19:33 Go to previous messageGo to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
Tom Schindl wrote:
> PlatformUI.getWorkbench().getProgressService().
>
> Tom
>

Thanks for the quick reply; that looks familiar, now that I see it, and
I'm sure it is what I was thinking of. In some prior project, I believe
I used it with success -- but this time, the ProgressMonitorDialog only
appears in the last about 0.3 secs of the operation, no matter how long
the operation takes ...

Presumably my operation is doing something unexpected by the PlatformUI
-- any clues as to what sorts of things might be causing such a problem?

thanks,
Paul
Re: BusyIndicator vs ProgressMonitorDialog [message #331201 is a reply to message #331193] Thu, 28 August 2008 04:07 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
In your someRunnableWithProgress class, are you calling the
progressMonitor.beginTask() as soon as the run method is called?


- Prakash

www.blog.eclipse-tips.com


Paul Th. Keyser wrote:
> Tom Schindl wrote:
>> PlatformUI.getWorkbench().getProgressService().
>>
>> Tom
>>
>
> Thanks for the quick reply; that looks familiar, now that I see it, and
> I'm sure it is what I was thinking of. In some prior project, I believe
> I used it with success -- but this time, the ProgressMonitorDialog only
> appears in the last about 0.3 secs of the operation, no matter how long
> the operation takes ...
>
> Presumably my operation is doing something unexpected by the PlatformUI
> -- any clues as to what sorts of things might be causing such a problem?
>
> thanks,
> Paul
Re: BusyIndicator vs ProgressMonitorDialog [message #331232 is a reply to message #331201] Thu, 28 August 2008 14:46 Go to previous messageGo to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
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
Re: BusyIndicator vs ProgressMonitorDialog [message #331255 is a reply to message #331232] Thu, 28 August 2008 15:21 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: BusyIndicator vs ProgressMonitorDialog [message #331284 is a reply to message #331255] Thu, 28 August 2008 19:15 Go to previous message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
Mario Winterer wrote:
> There seems to be something wrong in your code.
> You wrote you are calling busyCursorWhile INSIDE your run method?
>
Er, sorry, I did not describe what I am doing correctly. Let me try again:

try {
IRunnableWithProgress runnable = makeRunnableWithProgress(...);
PlatformUI.getWorkbench().getProgressService().
busyCursorWhile(runnable);

} catch (InvocationTargetException ite) {
logError(ite.getCause());

} catch (InterruptedException ie) {
; // since 'cancel' == false, this should never happen
}


// and then, the body of the method makeRunnableWithProgress() is:

return new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
if (null != monitor) {
String msg = ...;
monitor.beginTask(msg, IProgressMonitor.UNKNOWN);
}
try {
myLongTask();

} finally {
if (null != monitor) {
monitor.done();
}
}
}
};

-Paul
Previous Topic:Error Log entry: cannot bind to an undefined command
Next Topic:dropdown menu in view toolbar
Goto Forum:
  


Current Time: Tue Nov 12 04:46:08 GMT 2024

Powered by FUDForum. Page generated in 0.03109 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top