1 package eu
.etaxonomy
.taxeditor
.editor
.validation
;
5 import org
.apache
.log4j
.Logger
;
6 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
7 import org
.eclipse
.core
.runtime
.IStatus
;
8 import org
.eclipse
.core
.runtime
.Status
;
9 import org
.eclipse
.core
.runtime
.jobs
.Job
;
11 import eu
.etaxonomy
.cdm
.api
.service
.IEntityValidationService
;
12 import eu
.etaxonomy
.cdm
.model
.validation
.EntityValidation
;
13 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
14 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
15 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
18 * A job that repeatedly checks the error tables and refreshes the problem
19 * markers created from them.
21 * @author ayco_holleman
24 public class ValidationDaemon
extends Job
{
25 @SuppressWarnings("unused")
26 private static final Logger logger
= Logger
.getLogger(ValidationDaemon
.class);
28 private final IEntityValidationService entityValidationService
;
30 // Might want to make this configurable:
31 private int SLEEP_TIME
= 5000;
33 private boolean cancelRequested
= false;
37 public ValidationDaemon(){
38 super(Messages
.ValidationDaemon_RUNNING_DAEMON
);
39 entityValidationService
= CdmStore
.getService(IEntityValidationService
.class);
44 protected void canceling(){
45 cancelRequested
= true;
50 * This method is called by {@link ValidationContextListener} rather than
51 * {@link Job#cancel()}, because that method does not have the desired
54 public void setCancelRequested(){
55 cancelRequested
= true;
60 protected IStatus
run(IProgressMonitor monitor
){
61 MarkerManager markerManager
;
62 List
<EntityValidation
> results
;
64 while (!cancelRequested
) {
65 results
= entityValidationService
.getValidationResults();
66 markerManager
= new MarkerManager(results
);
67 markerManager
.deleteObsoleteMarkers();
68 markerManager
.createMarkers();
69 Thread
.sleep(SLEEP_TIME
);
71 MessagingUtils
.info(Messages
.ValidationDaemon_VALIDATION_STOPPED
);
72 return Status
.OK_STATUS
;
75 MessagingUtils
.info(Messages
.ValidationDaemon_VALIDATION_EXCEPTION
+ t
.getMessage());
76 return Status
.CANCEL_STATUS
;