Update TableViewer with event from a Job [message #892398] |
Thu, 28 June 2012 02:26  |
Eclipse User |
|
|
|
Hi,
I have a TableViewer containing a list of jobs:
Name State
JobA Not started
When I select a Job it will be started and executed with something like:
final Job job = new Job("JobA") {
protected IStatus run(IProgressMonitor monitor) {
try {
while(hasMoreWorkToDo()) {
// do some work
// ...
if (monitor.isCanceled()) return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
} finally {
schedule(60000); // start again in an hour
}
}
};
Then I have added a job change listener so that I know if job was executed successfully ( no interrupt). If it was successful I want to update the "State"
of the Job.
job.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
if (event.getResult().isOK())
postMessage("Job completed successfully");
//Send event possible to update data used in table viewer.
else
postError("Job did not complete successfully");
}
});
I have a Job object for each row in the table. Name is unique.
Is there any specific support for eclipse for handling events or should I use the
regular java java.util.EventObject and add my own listener on the Job object?
br,
//mike
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04236 seconds