Skip to main content



      Home
Home » Newcomers » Newcomers » Jobs and Scheduling
Jobs and Scheduling [message #227323] Tue, 14 August 2007 11:19 Go to next message
Eclipse UserFriend
Originally posted by: bkheck.gmail.com

Hi all. I have an import wizard that does some searching for a specific
file extension. I am trying to show a ProgressIndicator to the user to
indicate that the searching is taking place, as the search may take a
long time depending on the directory being searched. I found out the
hard way that if I call ProgressIndicator.beginAnimatedTask() and then
call my search, they both run in the UI thread and the ProgressIndicator
is not displayed. I am now trying to use a Job for my searching so that
I can display the ProgressIndicator to the user while the searching is
going on. The problem I'm having now, however, is that
ProgressIndicator.done() is being called before the search begins, and
the ProgressIndicator is not being displayed. The basic flow is as follows:

progressIndicator.beginAnimatedTask();

Job searchJob = new Job("Searching") {
@Override
protected IStatus run(IProgressMonitor monitor) {
searcher.search(directory);
}
}
searchJob.schedule();
progressIndicator.done();

I have read some articles about jobs and I have searched the e.platform,
e.rcp, and e.swt newsgroups for someone having a similar problem, but I
can't find anything that I have been able to apply to the situation that
I am in. Can anyone help?

Thanks in advance,
Brandon
Re: Jobs and Scheduling [message #227362 is a reply to message #227323] Tue, 14 August 2007 16:45 Go to previous messageGo to next message
Eclipse UserFriend
Brandon,

I'm not sure whether it'll work in your case or not but you can try this

progressIndicator.beginAnimatedTask();

Job searchJob = new Job("Searching") {
@Override
protected IStatus run(IProgressMonitor monitor) {
searcher.search(directory);
return Status.OK_STATUS;
}
}
searchJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
if (event.getResult().equals(Status.OK_STATUS)) {
progressIndicator.done();
}
}

};
searchJob.schedule();


All this does is that it ensures that progressIndicator.done() gets
called only when job is finished.

Hope that helps.

-tanmay


Brandon Heck wrote:
> Hi all. I have an import wizard that does some searching for a specific
> file extension. I am trying to show a ProgressIndicator to the user to
> indicate that the searching is taking place, as the search may take a
> long time depending on the directory being searched. I found out the
> hard way that if I call ProgressIndicator.beginAnimatedTask() and then
> call my search, they both run in the UI thread and the ProgressIndicator
> is not displayed. I am now trying to use a Job for my searching so that
> I can display the ProgressIndicator to the user while the searching is
> going on. The problem I'm having now, however, is that
> ProgressIndicator.done() is being called before the search begins, and
> the ProgressIndicator is not being displayed. The basic flow is as follows:
>
> progressIndicator.beginAnimatedTask();
>
> Job searchJob = new Job("Searching") {
> @Override
> protected IStatus run(IProgressMonitor monitor) {
> searcher.search(directory);
> }
> }
> searchJob.schedule();
> progressIndicator.done();
>
> I have read some articles about jobs and I have searched the e.platform,
> e.rcp, and e.swt newsgroups for someone having a similar problem, but I
> can't find anything that I have been able to apply to the situation that
> I am in. Can anyone help?
>
> Thanks in advance,
> Brandon
Re: Jobs and Scheduling [message #227369 is a reply to message #227362] Tue, 14 August 2007 17:07 Go to previous message
Eclipse UserFriend
Originally posted by: bkheck.gmail.com

Thanks Tanmay. That worked!

Brandon


Tanmay Sinha wrote:
> Brandon,
>
> I'm not sure whether it'll work in your case or not but you can try this
>
> progressIndicator.beginAnimatedTask();
>
> Job searchJob = new Job("Searching") {
> @Override
> protected IStatus run(IProgressMonitor monitor) {
> searcher.search(directory);
> return Status.OK_STATUS;
> }
> }
> searchJob.addJobChangeListener(new JobChangeAdapter() {
> @Override
> public void done(IJobChangeEvent event) {
> if (event.getResult().equals(Status.OK_STATUS)) {
> progressIndicator.done();
> }
> }
>
> };
> searchJob.schedule();
>
>
> All this does is that it ensures that progressIndicator.done() gets
> called only when job is finished.
>
> Hope that helps.
>
> -tanmay
>
>
> Brandon Heck wrote:
>> Hi all. I have an import wizard that does some searching for a
>> specific file extension. I am trying to show a ProgressIndicator to
>> the user to indicate that the searching is taking place, as the search
>> may take a long time depending on the directory being searched. I
>> found out the hard way that if I call
>> ProgressIndicator.beginAnimatedTask() and then call my search, they
>> both run in the UI thread and the ProgressIndicator is not displayed.
>> I am now trying to use a Job for my searching so that I can display
>> the ProgressIndicator to the user while the searching is going on. The
>> problem I'm having now, however, is that ProgressIndicator.done() is
>> being called before the search begins, and the ProgressIndicator is
>> not being displayed. The basic flow is as follows:
>>
>> progressIndicator.beginAnimatedTask();
>>
>> Job searchJob = new Job("Searching") {
>> @Override
>> protected IStatus run(IProgressMonitor monitor) {
>> searcher.search(directory);
>> }
>> }
>> searchJob.schedule();
>> progressIndicator.done();
>>
>> I have read some articles about jobs and I have searched the
>> e.platform, e.rcp, and e.swt newsgroups for someone having a similar
>> problem, but I can't find anything that I have been able to apply to
>> the situation that I am in. Can anyone help?
>>
>> Thanks in advance,
>> Brandon
Previous Topic:Using Eclipse as a Platform
Next Topic:Need Help Configuring Eclipse to Debug Plugin (Command Line)
Goto Forum:
  


Current Time: Sat Jun 07 12:00:42 EDT 2025

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

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

Back to the top