BusyIndicator vs ProgressMonitorDialog [message #331189] |
Wed, 27 August 2008 14: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 14: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 #331284 is a reply to message #331255] |
Thu, 28 August 2008 15: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.03769 seconds