Implementing a Progress Monitor Dialog [message #161574] |
Mon, 19 November 2007 22:33 |
Eclipse User |
|
|
|
Originally posted by: trommas.yahoo.com
The user of my editor will be able to load a file. This can take a
while, so I figured a progress bar dialog would smooth things. I am
using JFace dialogs in other parts of my application, so I though about
using: org.eclipse.jface.dialogs.ProgressMonitorDialog.
I have found various examples on the net, but has anyone here
implemented a progress monitor before? I would love to see an example in
a gmf context :)
Best Regrads,
Tomas Zijdemans
|
|
|
Re: Implementing a Progress Monitor Dialog [message #161613 is a reply to message #161574] |
Tue, 20 November 2007 07:32 |
Eclipse User |
|
|
|
Originally posted by: external.deyaa.adranale.de.bosch.com
Hi,
one way that is implemented in my program is to use
org.eclipse.jface.operation.IRunnableWithProgress as follows:
1. implement the interface
org.eclipse.jface.operation.IRunnableWithProgress
private class RunnableWithProgress implements IRunnableWithProgress {
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
monitor.beginTask("task description", workunits);
// some work should be here
monitor.worked(someunits);
// extra work can be here.
monitor.done();
}
}
2. on the ok button click of your dialog or the performFinish() of your
wizard, you can write something like this:
this.getContainer().run(fork, cancelable, new RunnableWithProgress());
that's it
i hope it will of some help.
----------
Deyaa
|
|
|
Re: Implementing a Progress Monitor Dialog [message #161650 is a reply to message #161613] |
Tue, 20 November 2007 09:51 |
Eclipse User |
|
|
|
Originally posted by: trommas.yahoo.com
For file loading, this seems fitting:
InputStream in = new BufferedInputStream(new
ProgressMonitorInputStream(null, "Loading: " + "filename", new
FileInputStream(filename)));
The bad thing with this, is that it isn't jface - so the userface
becomes inconsistent.
Regards,
Tomas Zijdemans
Deyaa wrote:
> Hi,
>
> one way that is implemented in my program is to use
> org.eclipse.jface.operation.IRunnableWithProgress as follows:
>
> 1. implement the interface
> org.eclipse.jface.operation.IRunnableWithProgress
> private class RunnableWithProgress implements IRunnableWithProgress {
> public void run(IProgressMonitor monitor)
> throws InvocationTargetException, InterruptedException {
> monitor.beginTask("task description", workunits);
> // some work should be here
> monitor.worked(someunits);
> // extra work can be here. monitor.done();
> }
> }
>
> 2. on the ok button click of your dialog or the performFinish() of your
> wizard, you can write something like this:
> this.getContainer().run(fork, cancelable, new RunnableWithProgress());
>
>
> that's it
> i hope it will of some help.
>
>
> ----------
> Deyaa
>
|
|
|
Powered by
FUDForum. Page generated in 0.23704 seconds