BusyIndicator vs ProgressMonitorDialog [message #331189] |
Wed, 27 August 2008 18:44  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
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
|
|
|
Re: BusyIndicator vs ProgressMonitorDialog [message #331284 is a reply to message #331255] |
Thu, 28 August 2008 19:15  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03542 seconds