1 11 package org.eclipse.search2.internal.ui; 12 13 import org.eclipse.core.runtime.IStatus; 14 15 import org.eclipse.swt.widgets.Shell; 16 17 import org.eclipse.jface.action.Action; 18 import org.eclipse.jface.dialogs.ErrorDialog; 19 import org.eclipse.jface.dialogs.ProgressMonitorDialog; 20 21 import org.eclipse.search.ui.ISearchQuery; 22 import org.eclipse.search.ui.ISearchResult; 23 import org.eclipse.search.ui.NewSearchUI; 24 25 import org.eclipse.search.internal.ui.SearchPluginImages; 26 27 class SearchAgainAction extends Action { 28 private SearchView fView; 29 30 public SearchAgainAction(SearchView view) { 31 setText(SearchMessages.SearchAgainAction_label); 32 setToolTipText(SearchMessages.SearchAgainAction_tooltip); 33 SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_AGAIN); 34 fView= view; 35 } 36 37 public void run() { 38 final ISearchResult search= fView.getCurrentSearchResult(); 39 if (search != null) { 40 ISearchQuery query= search.getQuery(); 41 NewSearchUI.cancelQuery(query); 42 if (query.canRerun()) { 43 if (query.canRunInBackground()) 44 NewSearchUI.runQueryInBackground(query, fView); 45 else { 46 Shell shell= fView.getSite().getShell(); 47 ProgressMonitorDialog pmd= new ProgressMonitorDialog(shell); 48 IStatus status= NewSearchUI.runQueryInForeground(pmd, query, fView); 49 if (!status.isOK() && status.getSeverity() != IStatus.CANCEL) { 50 ErrorDialog.openError(shell, SearchMessages.SearchAgainAction_Error_title, SearchMessages.SearchAgainAction_Error_message, status); 51 } 52 } 53 } 54 } 55 } 56 } 57 | Popular Tags |