Search in sources :

Example 1 with TextSearchQueryProvider

use of org.eclipse.search.ui.text.TextSearchQueryProvider in project eclipse.platform.text by eclipse.

the class RetrieverAction method run.

@Override
public void run() {
    IWorkbenchPage page = getWorkbenchPage();
    if (page == null) {
        return;
    }
    TextSearchQueryProvider provider = TextSearchQueryProvider.getPreferred();
    String searchForString = getSearchForString(page);
    if (searchForString.length() == 0) {
        MessageDialog.openInformation(getShell(), SearchMessages.RetrieverAction_dialog_title, SearchMessages.RetrieverAction_empty_selection);
        return;
    }
    try {
        ISearchQuery query = createQuery(provider, searchForString);
        if (query != null) {
            NewSearchUI.runQueryInBackground(query);
        }
    } catch (OperationCanceledException ex) {
    // action cancelled
    } catch (CoreException e) {
        ErrorDialog.openError(getShell(), SearchMessages.RetrieverAction_error_title, SearchMessages.RetrieverAction_error_message, e.getStatus());
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) TextSearchQueryProvider(org.eclipse.search.ui.text.TextSearchQueryProvider) ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 2 with TextSearchQueryProvider

use of org.eclipse.search.ui.text.TextSearchQueryProvider in project eclipse.platform.text by eclipse.

the class TextSearchQueryProviderRegistry method createFromExtension.

private TextSearchQueryProvider createFromExtension(final String id) {
    final TextSearchQueryProvider[] res = new TextSearchQueryProvider[] { null };
    SafeRunnable safe = new SafeRunnable() {

        @Override
        public void run() throws Exception {
            IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_ID);
            for (IConfigurationElement curr : extensions) {
                if (PROVIDER_NODE_NAME.equals(curr.getName()) && id.equals(curr.getAttribute(ATTRIB_ID))) {
                    res[0] = (TextSearchQueryProvider) curr.createExecutableExtension(ATTRIB_CLASS);
                    return;
                }
            }
        }

        @Override
        public void handleException(Throwable e) {
            SearchPlugin.log(e);
        }
    };
    SafeRunnable.run(safe);
    return res[0];
}
Also used : SafeRunnable(org.eclipse.jface.util.SafeRunnable) TextSearchQueryProvider(org.eclipse.search.ui.text.TextSearchQueryProvider) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

TextSearchQueryProvider (org.eclipse.search.ui.text.TextSearchQueryProvider)2 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 SafeRunnable (org.eclipse.jface.util.SafeRunnable)1 ISearchQuery (org.eclipse.search.ui.ISearchQuery)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1