// TODO: check if editor is dirty before running
final String marker = getMarker();
final IResource resource = getResource();
final MarkerUtilities factory = new MarkerUtilities(getLog(), getPluginId());
Job job =
new Job(getJobTitle(resource))
{
protected IStatus run(IProgressMonitor monitor)
{
// cancelled while sitting in queue
if (monitor.isCanceled()) { return Status.CANCEL_STATUS; }
factory.deleteMarkers(resource, marker);
/*
* this should be able to support multiple resources as well in the future - the
* loop would just need to include a check against the monitor for cancellation
*/
Object[] violations = doJob(resource);
// check if we were cancelled while the thread was running
if (monitor.isCanceled()) { return Status.CANCEL_STATUS; }
for (int i = 0; i < violations.length; i++)
{
Map attributes = createMarkerAttributes(factory, violations[i]);
factory.createMarker(resource, marker, attributes);
}
return Status.OK_STATUS;
}
};