Class NewSearchUI
- Since:
- 3.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Id of the Search action set (value"org.eclipse.search.searchActionSet"
).static final String
Search Plug-in Id (value"org.eclipse.search"
).static final String
Search marker type (value"org.eclipse.search.searchmarker"
).static final String
Id of the new Search view (value"org.eclipse.search.ui.views.SearchView"
). -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ISearchResultViewPart
Activates a search result view in the current workbench window page.static void
Registers the given listener to receive notification of changes to queries.static boolean
Returns the preference whether a search engine is allowed to report potential matches or not.static void
cancelQuery
(ISearchQuery query) Sends a 'cancel' command to the given query running in background.static String
Returns the ID of the default perspective.static ISearchQuery[]
Returns all search queries know to the search UI (i.e. registered viarunQuery()
orrunQueryInForeground())
.static ISearchResultViewPart
Gets the search result view shown in the current workbench window.static boolean
isQueryRunning
(ISearchQuery query) Returns whether the given query is currently running.static void
openSearchDialog
(IWorkbenchWindow window, String pageId) Opens the search dialog.static void
removeQuery
(ISearchQuery query) Removes the given search query.static void
Removes the given query listener.static boolean
Returns the preference whether editors should be reused when showing search results.static void
runQuery
(ISearchQuery query) Deprecated.deprecated in 3.1.static void
runQueryInBackground
(ISearchQuery query) Runs the given search query.static void
runQueryInBackground
(ISearchQuery query, ISearchResultViewPart view) Runs the given search query.static IStatus
runQueryInForeground
(IRunnableContext context, ISearchQuery query) Runs the given search query.static IStatus
runQueryInForeground
(IRunnableContext context, ISearchQuery query, ISearchResultViewPart view) Runs the given search query.
-
Field Details
-
PLUGIN_ID
Search Plug-in Id (value"org.eclipse.search"
).- See Also:
-
SEARCH_MARKER
Search marker type (value"org.eclipse.search.searchmarker"
).- See Also:
-
SEARCH_VIEW_ID
Id of the new Search view (value"org.eclipse.search.ui.views.SearchView"
).- See Also:
-
ACTION_SET_ID
Id of the Search action set (value"org.eclipse.search.searchActionSet"
).- See Also:
-
-
Constructor Details
-
NewSearchUI
public NewSearchUI()
-
-
Method Details
-
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
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.deprecated in 3.1. UserunQueryInBackground(ISearchQuery)
to run a query in background orrunQueryInForeground(IRunnableContext, ISearchQuery)
to run it in foregroundRuns the given search query. This method may run the given query in a separate thread ifISearchQuery#canRunInBackground()
returnstrue
. Running a query adds it to the set of known queries and notifies any registeredIQueryListener
s about the addition.- Parameters:
query
- the query to execute
-
runQueryInBackground
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 registeredIQueryListener
s 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 meansISearchQuery.canRunInBackground()
must betrue
- 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 registeredIQueryListener
s 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 meansISearchQuery.canRunInBackground()
must betrue
view
- the search result view to show the result in. Ifnull
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
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 registeredIQueryListener
s 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 inquery
- 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 registeredIQueryListener
s 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 inquery
- the query to executeview
- the search result view to show the result in. Ifnull
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
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
Removes the given query listener. Does nothing if the listener is not present.- Parameters:
l
- the listener to be removed.
-
getQueries
Returns all search queries know to the search UI (i.e. registered viarunQuery()
orrunQueryInForeground())
.- Returns:
- all search results
-
isQueryRunning
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
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
Removes the given search query.- Parameters:
query
- the query to be removed- Since:
- 3.5
-
openSearchDialog
Opens the search dialog. IfpageId
is specified and a corresponding page is found then it is brought to top.- Parameters:
window
- the parent windowpageId
- the page to select ornull
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
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
-