Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to show a job's progress within a wizard
How to show a job's progress within a wizard [message #527030] Tue, 13 April 2010 18:25 Go to next message
Sascha Zak is currently offline Sascha ZakFriend
Messages: 11
Registered: July 2009
Junior Member
Hello again,

my problem is as follows:

I have several wizards with pages calling methods with long running
opearations (implemented as Jobs) for which I want to show a progress
bar without knowing, that they are Jobs.

I'll try to build an example:

public class SomeWizard extens Wizard implements INewWizard {
....

void refreshPage(IItemProvider provider) {
...
Set<Item> items = provider.getItems();
...
}
....
}

public class ItemProvider implements IItemProvider {
....
@Override
public Set<Item> getItems() {
...
ItemJob itemJob = new ItemJob();
itemJob.setUser(true);
itemJob.schedule();
itemJob.join();

return itemJob.getResult();
}
....
}



If I call these methods from a command handler, the usual progress
dialog is raised. But if I call these methods within a wizard or wizard
page, the progress dialog (and also the indicator in the trim) does not
show, probably because the wizard is already a dialog.

Does anyone know, how either force the progress dialog to be shown or
how to integrate any job's progress into a wizard's progress bar.

The following things I've tried already:

- Extends WizardDialog setting it to non-modal:
no effect except the dialog isn't modal anymore :)

- Providing the wizards progress monitor in a custom service and
obtaining it within the (subsequent) executed job from the service:
modification of the obtained mointor results in an "invalid thread
access" (which makes sense afterwards)

Hope anyone has an idea.

Thanks in advance.

Best regards

Sascha
Re: How to show a job's progress within a wizard [message #527213 is a reply to message #527030] Wed, 14 April 2010 13:45 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 418
Registered: July 2009
Senior Member
Hi,

This code exits in org.eclipse.egit.ui.internal.clone.GitCloneWizard

In your wizard you can do this:

op = your runner with monitor.

try {
// Perform clone in ModalContext thread with progress
// reporting on the wizard.
getContainer().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException,
InterruptedException {
op.run(monitor);
}
});

--

Best Regards,
Wim Jongman
-- Does fuzzy logic tickle?
(Eclipse Old Skool Quote Service)

> Hello again,
>
> my problem is as follows:
>
> I have several wizards with pages calling methods with long running
> opearations (implemented as Jobs) for which I want to show a progress
> bar without knowing, that they are Jobs.
>
> I'll try to build an example:
>
> public class SomeWizard extens Wizard implements INewWizard {
> ....
>
> void refreshPage(IItemProvider provider) {
> ...
> Set<Item> items = provider.getItems();
> ...
> }
> ....
> }
>
> public class ItemProvider implements IItemProvider {
> ....
> @Override
> public Set<Item> getItems() {
> ...
> ItemJob itemJob = new ItemJob();
> itemJob.setUser(true);
> itemJob.schedule();
> itemJob.join();
>
> return itemJob.getResult();
> }
> ....
> }
>
>
>
> If I call these methods from a command handler, the usual progress
> dialog is raised. But if I call these methods within a wizard or wizard
> page, the progress dialog (and also the indicator in the trim) does not
> show, probably because the wizard is already a dialog.
>
> Does anyone know, how either force the progress dialog to be shown or
> how to integrate any job's progress into a wizard's progress bar.
>
> The following things I've tried already:
>
> - Extends WizardDialog setting it to non-modal:
> no effect except the dialog isn't modal anymore :)
>
> - Providing the wizards progress monitor in a custom service and
> obtaining it within the (subsequent) executed job from the service:
> modification of the obtained mointor results in an "invalid thread
> access" (which makes sense afterwards)
>
> Hope anyone has an idea.
>
> Thanks in advance.
>
> Best regards
>
> Sascha
Re: How to show a job's progress within a wizard [message #527273 is a reply to message #527213] Wed, 14 April 2010 15:54 Go to previous messageGo to next message
Sascha Zak is currently offline Sascha ZakFriend
Messages: 11
Registered: July 2009
Junior Member
Hi Wim,

thanks for your hint, however this is not what I wanted, because
I have no Runnable within my wizard but a Job subsequently scheduled.

Now I found out, that my solution to publish the monitor from the wizard
to a service and implementing the job to call the service looking for
any provided monitors (and use them) DOES work, if the monitor is
accessed within the UI thread (which can be done the usual way).

I think that's not as clean as could be but for my developer nose it
smells not too strong :)

So this is just another question I've answered myself :)
Thanks anyway.

Best regards
Sascha




Am 14.04.2010 15:45, schrieb Wim Jongman:
> Hi,
>
> This code exits in org.eclipse.egit.ui.internal.clone.GitCloneWizard
>
> In your wizard you can do this:
>
> op = your runner with monitor.
>
> try {
> // Perform clone in ModalContext thread with progress
> // reporting on the wizard.
> getContainer().run(true, true, new IRunnableWithProgress() {
> public void run(IProgressMonitor monitor)
> throws InvocationTargetException,
> InterruptedException {
> op.run(monitor);
> }
> });
>
Re: How to show a job's progress within a wizard [message #527282 is a reply to message #527273] Wed, 14 April 2010 16:04 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 418
Registered: July 2009
Senior Member
Hi Sascha,

> for my developer nose it smells not too strong :)

I think you have a cold... ;-)

The job has a run(monitor) method. Why not call that in the wizard like this:

op = your job


try {
// Perform clone in ModalContext thread with progress
// reporting on the wizard.
getContainer().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException,
InterruptedException {
op.run(monitor);
}

That really smells like roses!

--

Best Regards,
Wim Jongman
-- ... File not found. Should I fake it? (Y/N)
(Eclipse Old Skool Quote Service)

> Hi Wim,
>
> thanks for your hint, however this is not what I wanted, because
> I have no Runnable within my wizard but a Job subsequently scheduled.
>
> Now I found out, that my solution to publish the monitor from the wizard
> to a service and implementing the job to call the service looking for
> any provided monitors (and use them) DOES work, if the monitor is
> accessed within the UI thread (which can be done the usual way).
>
> I think that's not as clean as could be but
for my developer nose it
> smells not too strong :)
>
> So this is just another question I've answered myself :)
> Thanks anyway.
>
> Best regards
> Sascha
>
>
>
>
> Am 14.04.2010 15:45, schrieb Wim Jongman:
>> Hi,
>>
>> This code exits in org.eclipse.egit.ui.internal.clone.GitCloneWizard
>>
>> In your wizard you can do this:
>>
>> op = your runner with monitor.
>>
>> try {
>> // Perform clone in ModalContext thread with progress
>> // reporting on the wizard.
>> getContainer().run(true, true, new IRunnableWithProgress() {
>> public void run(IProgressMonitor monitor)
>> throws InvocationTargetException,
>> InterruptedException {
>> op.run(monitor);
>> }
>> });
>>
Re: How to show a job's progress within a wizard [message #527362 is a reply to message #527282] Thu, 15 April 2010 03:53 Go to previous messageGo to next message
Sascha Zak is currently offline Sascha ZakFriend
Messages: 11
Registered: July 2009
Junior Member
Hi Wim,

thanks for nose-caring :)
I agree with you, but my wizard also doesn't know that there's a job,
that's why I said 'subsequently'.

My wizard has got a simple interface which it uses calling methods
provided by this interface. The implementation of the interface comes
from another bundle and in some methods it does it's work by scheduling
a job. But this is completely hidden from the wizard.

Otherwise your solution would be the right way I think.




Am 14.04.2010 18:04, schrieb Wim Jongman:
> Hi Sascha,
>
>> for my developer nose it smells not too strong :)
>
> I think you have a cold... ;-)
>
> The job has a run(monitor) method. Why not call that in the wizard like this:
>
> op = your job
>
>
> try {
> // Perform clone in ModalContext thread with progress
> // reporting on the wizard.
> getContainer().run(true, true, new IRunnableWithProgress() {
> public void run(IProgressMonitor monitor)
> throws InvocationTargetException,
> InterruptedException {
> op.run(monitor);
> }
>
> That really smells like roses!
>
Re: How to show a job's progress within a wizard [message #527363 is a reply to message #527030] Thu, 15 April 2010 04:17 Go to previous message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
You need to wrap the job & runnable. Else you have to wait till
https://bugs.eclipse.org/bugs/show_bug.cgi?id=293098 is fixed

- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Previous Topic:Associating javadoc with a plugin
Next Topic:Icon Sharing between plugins
Goto Forum:
  


Current Time: Sat Dec 20 15:08:38 GMT 2014

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

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