if (JavaPlugin.getDefault().getPreferenceStore().getBoolean(WorkInProgressPreferencePage.PREF_BGSEARCH)) { try { performNewSearch(element); } catch (JavaModelException ex) { ExceptionHandler.handle(ex, getShell(), SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); } } else { SearchUI.activateSearchResultView(); Shell shell= JavaPlugin.getActiveWorkbenchShell(); JavaSearchOperation op= null; try { op= makeOperation(element); if (op == null) return; } catch (JavaModelException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); return; } IWorkspaceDescription workspaceDesc= JavaPlugin.getWorkspace().getDescription(); boolean isAutoBuilding= workspaceDesc.isAutoBuilding(); if (isAutoBuilding) {  workspaceDesc.setAutoBuilding(false); try { JavaPlugin.getWorkspace().setDescription(workspaceDesc); } catch (CoreException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.setDescription.title"), SearchMessages.getString("Search.Error.setDescription.message")); } } try { new ProgressMonitorDialog(shell).run(true, true, op); } catch (InvocationTargetException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); } catch(InterruptedException e) {  } finally { if (isAutoBuilding) {  workspaceDesc= JavaPlugin.getWorkspace().getDescription(); workspaceDesc.setAutoBuilding(true); try { JavaPlugin.getWorkspace().setDescription(workspaceDesc); } catch (CoreException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.setDescription.title"), SearchMessages.getString("Search.Error.setDescription.message")); } } } }
run(element);
	public void run(IJavaElement element) {				if (!ActionUtil.isProcessable(getShell(), element))			return;						if (JavaPlugin.getDefault().getPreferenceStore().getBoolean(WorkInProgressPreferencePage.PREF_BGSEARCH)) {			try {			performNewSearch(element);		} catch (JavaModelException ex) {			ExceptionHandler.handle(ex, getShell(), SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-1$ //$NON-NLS-2$		}		} else {			SearchUI.activateSearchResultView();			Shell shell= JavaPlugin.getActiveWorkbenchShell();			JavaSearchOperation op= null;			try {				op= makeOperation(element);				if (op == null)					return;			} catch (JavaModelException ex) {				ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-1$ //$NON-NLS-2$				return;			}			IWorkspaceDescription workspaceDesc= JavaPlugin.getWorkspace().getDescription();			boolean isAutoBuilding= workspaceDesc.isAutoBuilding();			if (isAutoBuilding) {				// disable auto-build during search operation				workspaceDesc.setAutoBuilding(false);				try {					JavaPlugin.getWorkspace().setDescription(workspaceDesc);				}				catch (CoreException ex) {					ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.setDescription.title"), SearchMessages.getString("Search.Error.setDescription.message")); //$NON-NLS-1$ //$NON-NLS-2$				}			}			try {				new ProgressMonitorDialog(shell).run(true, true, op);			} catch (InvocationTargetException ex) {				ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-1$ //$NON-NLS-2$			} catch(InterruptedException e) {				// means it's cancelled			} finally {				if (isAutoBuilding) {					// enable auto-building again					workspaceDesc= JavaPlugin.getWorkspace().getDescription();					workspaceDesc.setAutoBuilding(true);					try {						JavaPlugin.getWorkspace().setDescription(workspaceDesc);					}					catch (CoreException ex) {						ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.setDescription.title"), SearchMessages.getString("Search.Error.setDescription.message")); //$NON-NLS-1$ //$NON-NLS-2$					}				}							}		}	}