1 11 package org.eclipse.search.ui; 12 13 import org.eclipse.search.internal.ui.OpenSearchDialogAction; 14 import org.eclipse.search.internal.ui.SearchPlugin; 15 import org.eclipse.search.internal.ui.SearchPreferencePage; 16 import org.eclipse.search2.internal.ui.InternalSearchUI; 17 import org.eclipse.search2.internal.ui.SearchMessages; 18 19 import org.eclipse.core.runtime.IStatus; 20 21 import org.eclipse.jface.dialogs.ErrorDialog; 22 import org.eclipse.jface.operation.IRunnableContext; 23 24 import org.eclipse.ui.IWorkbenchWindow; 25 30 public class NewSearchUI { 31 39 public static ISearchResultViewPart activateSearchResultView() { 40 return InternalSearchUI.getInstance().getSearchViewManager().activateSearchView(false); 41 } 42 48 public static ISearchResultViewPart getSearchResultView() { 49 return InternalSearchUI.getInstance().getSearchViewManager().getActiveSearchView(); 50 } 51 64 public static void runQuery(ISearchQuery query) { 65 if (query == null) { 66 throw new IllegalArgumentException ("query must not be null"); } 68 if (query.canRunInBackground()) 69 runQueryInBackground(query); 70 else { 71 IStatus status= runQueryInForeground(null, query); 72 if (status != null) { 73 if (!status.isOK()) 74 SearchPlugin.log(status); 75 if (status.getSeverity() == IStatus.ERROR) { 76 ErrorDialog.openError(SearchPlugin.getActiveWorkbenchShell(), SearchMessages.NewSearchUI_error_title, SearchMessages.NewSearchUI_error_label, status); 77 } 78 } 79 } 80 } 81 82 98 public static void runQueryInBackground(ISearchQuery query) throws IllegalArgumentException { 99 if (query == null) { 100 throw new IllegalArgumentException ("query must not be null"); } 102 runQueryInBackground(query, null); 103 } 104 105 124 public static void runQueryInBackground(ISearchQuery query, ISearchResultViewPart view) throws IllegalArgumentException { 125 if (query == null) { 126 throw new IllegalArgumentException ("query must not be null"); } 128 if (query.canRunInBackground()) 129 InternalSearchUI.getInstance().runSearchInBackground(query, view); 130 else 131 throw new IllegalArgumentException ("Query can not be run in background"); } 133 134 151 public static IStatus runQueryInForeground(IRunnableContext context, ISearchQuery query) { 152 if (query == null) { 153 throw new IllegalArgumentException ("query must not be null"); } 155 return runQueryInForeground(context, query, null); 156 } 157 158 180 public static IStatus runQueryInForeground(IRunnableContext context, ISearchQuery query, ISearchResultViewPart view) { 181 if (query == null) { 182 throw new IllegalArgumentException ("query must not be null"); } 184 return InternalSearchUI.getInstance().runSearchInForeground(context, query, view); 185 } 186 187 196 public static void addQueryListener(IQueryListener l) { 197 InternalSearchUI.getInstance().addQueryListener(l); 198 } 199 206 public static void removeQueryListener(IQueryListener l) { 207 InternalSearchUI.getInstance().removeQueryListener(l); 208 } 209 215 public static ISearchQuery[] getQueries() { 216 return InternalSearchUI.getInstance().getQueries(); 217 } 218 219 229 public static boolean isQueryRunning(ISearchQuery query) { 230 if (query == null) { 231 throw new IllegalArgumentException ("query must not be null"); } 233 return InternalSearchUI.getInstance().isQueryRunning(query); 234 } 235 236 244 public static void cancelQuery(ISearchQuery query) { 245 if (query == null) { 246 throw new IllegalArgumentException ("query must not be null"); } 248 InternalSearchUI.getInstance().cancelSearch(query); 249 } 250 251 254 public static final String PLUGIN_ID= "org.eclipse.search"; 256 261 public static final String SEARCH_MARKER= PLUGIN_ID + ".searchmarker"; 263 267 public static final String SEARCH_VIEW_ID= "org.eclipse.search.ui.views.SearchView"; 269 273 public static final String ACTION_SET_ID= PLUGIN_ID + ".searchActionSet"; 275 276 285 public static void openSearchDialog(IWorkbenchWindow window, String pageId) { 286 new OpenSearchDialogAction(window, pageId).run(); 287 } 288 289 297 public static boolean reuseEditor() { 298 return SearchPreferencePage.isEditorReused(); 299 } 300 301 311 public static boolean arePotentialMatchesIgnored() { 312 return SearchPreferencePage.arePotentialMatchesIgnored(); 313 } 314 315 324 public static String getDefaultPerspectiveId() { 325 return SearchPreferencePage.getDefaultPerspectiveId(); 326 } 327 328 } 329 | Popular Tags |