|
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 |
Wim Jongman Messages: 423 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 |
Sascha Zak 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 |
Wim Jongman Messages: 423 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);
>> }
>> });
>>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03398 seconds