Bug 49599 Occurrences finder should use a job
Build: 3.0 M6 I noticed that the background task to find occurrences in the file creates a new thread every time, rather than using jobs. This is exactly the situation that jobs were created for (in fact Erich used this as a demo of the job infrastructure at a code camp). Some advantages of changing to jobs: - less overhead (currently a new thread is created per key press, jobs use a thread pool) - better handling of priority (currently running in a thread with same priority as the UI, and thus is competing with UI thread for CPU more than it should) - smarter scheduling. Jobs with "DECORATE" priority are run based on a check of how busy the system is. Thus they do not run immediately if there are other things going on (they will run eventually, just not as quickly). This smooths over bottlenecks when the system is busy. Note that you can prevent this job from showing in the progress view or making the progress animation (cigarette) move by making it a system job (Job.setSystem(true)). Generally jobs that the user didn't explicitly start can be marked as system jobs. If there was a reason why jobs were considered and rejected, I'd be curious to know. If the infrastructure isn't useful to you then I want to fix it.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
action= new RemoveOccurrenceAnnotations(this);
		action.setActionDefinitionId(IJavaEditorActionDefinitionIds.REMOVE_OCCURRENCE_ANNOTATIONS);
		setAction("RemoveOccurrenceAnnotations", action); 
	}
	
	public void updatedTitleImage(Image image) {
		setTitleImage(image);
	}
	
	/*
	 * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
	 */
	protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
		
		try {			
			ISourceViewer sourceViewer= getSourceViewer();
			if (sourceViewer == null)
				return;
				
			String property= event.getProperty();	
			
			if (PreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
				Object value= event.getNewValue();
				if (value instanceof Integer) {
					sourceViewer.getTextWidget().setTabs(((Integer) value).intValue());
				} else if (value instanceof String) {
					sourceViewer.getTextWidget().setTabs(Integer.parseInt((String) value));
				}
				return;
			}