Class NewSearchUI

java.lang.Object
org.eclipse.search.ui.NewSearchUI

public class NewSearchUI extends Object
A facade for access to the new search UI facilities.
Since:
3.0
  • Field Details

    • PLUGIN_ID

      public static final String PLUGIN_ID
      Search Plug-in Id (value "org.eclipse.search").
      See Also:
    • SEARCH_MARKER

      public static final String SEARCH_MARKER
      Search marker type (value "org.eclipse.search.searchmarker").
      See Also:
    • SEARCH_VIEW_ID

      public static final String SEARCH_VIEW_ID
      Id of the new Search view (value "org.eclipse.search.ui.views.SearchView").
      See Also:
    • ACTION_SET_ID

      public static final String ACTION_SET_ID
      Id of the Search action set (value "org.eclipse.search.searchActionSet").
      See Also:
  • Constructor Details

    • NewSearchUI

      public NewSearchUI()
  • Method Details

    • activateSearchResultView

      public static ISearchResultViewPart activateSearchResultView()
      Activates a search result view in the current workbench window page. If a search view is already open in the current workbench window page, it is activated. Otherwise a new search view is opened and activated.
      Returns:
      the activate search result view or null if the search result view couldn't be activated
    • getSearchResultView

      public static ISearchResultViewPart getSearchResultView()
      Gets the search result view shown in the current workbench window.
      Returns:
      the search result view or null, if none is open in the current workbench window page
    • runQuery

      @Deprecated public static void runQuery(ISearchQuery query)
      Deprecated.
      deprecated in 3.1. Use runQueryInBackground(ISearchQuery) to run a query in background or runQueryInForeground(IRunnableContext, ISearchQuery) to run it in foreground
      Runs the given search query. This method may run the given query in a separate thread if ISearchQuery#canRunInBackground() returns true. Running a query adds it to the set of known queries and notifies any registered IQueryListeners about the addition.
      Parameters:
      query - the query to execute
    • runQueryInBackground

      public static void runQueryInBackground(ISearchQuery query) throws IllegalArgumentException
      Runs the given search query. This method will execute the query in a background thread and not block until the search is finished. Running a query adds it to the set of known queries and notifies any registered IQueryListeners about the addition.

      The search view that shows the result will be activated. That means a call to activateSearchResultView() is not required.

      Parameters:
      query - the query to execute. The query must be able to run in background, that means ISearchQuery.canRunInBackground() must be true
      Throws:
      IllegalArgumentException - Thrown when the passed query is not able to run in background
      Since:
      3.1
    • runQueryInBackground

      public static void runQueryInBackground(ISearchQuery query, ISearchResultViewPart view) throws IllegalArgumentException
      Runs the given search query. This method will execute the query in a background thread and not block until the search is finished. Running a query adds it to the set of known queries and notifies any registered IQueryListeners about the addition.

      The result will be shown in the given search result view which will be activated. A call to to activateSearchResultView() is not required.

      Parameters:
      query - the query to execute. The query must be able to run in background, that means ISearchQuery.canRunInBackground() must be true
      view - the search result view to show the result in. If null is passed in, the default activation mechanism is used to open a new result view or to select the view to be reused.
      Throws:
      IllegalArgumentException - Thrown when the passed query is not able to run in background
      Since:
      3.2
    • runQueryInForeground

      public static IStatus runQueryInForeground(IRunnableContext context, ISearchQuery query)
      Runs the given search query. This method will execute the query in the same thread as the caller. This method blocks until the query is finished. Running a query adds it to the set of known queries and notifies any registered IQueryListeners about the addition.

      The result will be shown in a search view that will be activated. That means a call to activateSearchResultView() is not required.

      Parameters:
      context - the runnable context to run the query in
      query - the query to execute
      Returns:
      a status indicating whether the query ran correctly, including IStatus.CANCEL to signal that the query was canceled.
    • runQueryInForeground

      public static IStatus runQueryInForeground(IRunnableContext context, ISearchQuery query, ISearchResultViewPart view)
      Runs the given search query. This method will execute the query in the same thread as the caller. This method blocks until the query is finished. Running a query adds it to the set of known queries and notifies any registered IQueryListeners about the addition.

      The result will be shown in the given search result view which will be activated. A call to to activateSearchResultView() is not required.

      Parameters:
      context - the runnable context to run the query in
      query - the query to execute
      view - the search result view to show the result in. If null is passed in, the default activation mechanism is used to open a new result view or to select the view to be reused.
      Returns:
      a status indicating whether the query ran correctly, including IStatus.CANCEL to signal that the query was canceled.
      Since:
      3.2
    • addQueryListener

      public static void addQueryListener(IQueryListener l)
      Registers the given listener to receive notification of changes to queries. The listener will be notified whenever a query has been added, removed, is starting or has finished. Has no effect if an identical listener is already registered.
      Parameters:
      l - the listener to be added
    • removeQueryListener

      public static void removeQueryListener(IQueryListener l)
      Removes the given query listener. Does nothing if the listener is not present.
      Parameters:
      l - the listener to be removed.
    • getQueries

      public static ISearchQuery[] getQueries()
      Returns all search queries know to the search UI (i.e. registered via runQuery() or runQueryInForeground()).
      Returns:
      all search results
    • isQueryRunning

      public static boolean isQueryRunning(ISearchQuery query)
      Returns whether the given query is currently running. Queries may be run by client request or by actions in the search UI.
      Parameters:
      query - the query
      Returns:
      whether the given query is currently running
      See Also:
    • cancelQuery

      public static void cancelQuery(ISearchQuery query)
      Sends a 'cancel' command to the given query running in background. The call has no effect if the query is not running, not in background or is not cancelable.
      Parameters:
      query - the query
      Since:
      3.1
    • removeQuery

      public static void removeQuery(ISearchQuery query)
      Removes the given search query.
      Parameters:
      query - the query to be removed
      Since:
      3.5
    • openSearchDialog

      public static void openSearchDialog(IWorkbenchWindow window, String pageId)
      Opens the search dialog. If pageId is specified and a corresponding page is found then it is brought to top.
      Parameters:
      window - the parent window
      pageId - the page to select or null if the best fitting page should be selected
    • reuseEditor

      public static boolean reuseEditor()
      Returns the preference whether editors should be reused when showing search results. The goto action can decide to use or ignore this preference.
      Returns:
      true if editors should be reused for showing search results
    • arePotentialMatchesIgnored

      public static boolean arePotentialMatchesIgnored()
      Returns the preference whether a search engine is allowed to report potential matches or not.

      Search engines which can report inexact matches must respect this preference i.e. they should not report inexact matches if this method returns true

      Returns:
      true if search engine must not report inexact matches
    • getDefaultPerspectiveId

      public static String getDefaultPerspectiveId()
      Returns the ID of the default perspective.

      The perspective with this ID will be used to show the Search view. If no default perspective is set then the Search view will appear in the current perspective.

      Returns:
      the ID of the default perspective null if no default perspective is set