Search in sources :

Example 1 with ISearchQuery

use of org.eclipse.search.ui.ISearchQuery in project che by eclipse.

the class QueryManager method removeAll.

public void removeAll() {
    synchronized (this) {
        List old = fQueries;
        fQueries = new LinkedList();
        Iterator iter = old.iterator();
        while (iter.hasNext()) {
            ISearchQuery element = (ISearchQuery) iter.next();
            fireRemoved(element);
        }
    }
}
Also used : Iterator(java.util.Iterator) List(java.util.List) LinkedList(java.util.LinkedList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 2 with ISearchQuery

use of org.eclipse.search.ui.ISearchQuery in project xtext-eclipse by eclipse.

the class CompositeSearchQuery method run.

@Override
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
    SubMonitor progress = SubMonitor.convert(monitor, children.size());
    MultiStatus multiStatus = new MultiStatus(getPluginId(), IStatus.OK, "Composite search state", null);
    for (ISearchQuery child : children) {
        IStatus status = child.run(progress.newChild(1));
        multiStatus.add(status);
        if (progress.isCanceled()) {
            return Status.CANCEL_STATUS;
        }
    }
    return multiStatus;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) SubMonitor(org.eclipse.core.runtime.SubMonitor) MultiStatus(org.eclipse.core.runtime.MultiStatus) ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 3 with ISearchQuery

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

the class ShowSearchHistoryDialogAction method run.

@Override
public void run() {
    ISearchQuery[] queries = NewSearchUI.getQueries();
    ArrayList<ISearchResult> input = new ArrayList<>();
    for (ISearchQuery query : queries) {
        ISearchResult search = query.getSearchResult();
        input.add(search);
    }
    SearchHistorySelectionDialog dlg = new SearchHistorySelectionDialog(SearchPlugin.getActiveWorkbenchShell(), input);
    ISearchResult current = fSearchView.getCurrentSearchResult();
    if (current != null) {
        Object[] selected = new Object[1];
        selected[0] = current;
        dlg.setInitialSelections(selected);
    }
    if (dlg.open() == Window.OK) {
        Object[] result = dlg.getResult();
        if (result != null && result.length == 1) {
            ISearchResult searchResult = (ISearchResult) result[0];
            InternalSearchUI.getInstance().showSearchResult(fSearchView, searchResult, dlg.isOpenInNewView());
        }
    }
}
Also used : ISearchResult(org.eclipse.search.ui.ISearchResult) ArrayList(java.util.ArrayList) ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 4 with ISearchQuery

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

the class PositionTracker method bufferCreated.

// IFileBufferListener implementation ---------------------------------------------------------------------
@Override
public void bufferCreated(IFileBuffer buffer) {
    final int[] trackCount = new int[1];
    if (!(buffer instanceof ITextFileBuffer))
        return;
    IPath location = buffer.getLocation();
    if (location == null)
        return;
    IFile file = FileBuffers.getWorkspaceFileAtLocation(location);
    if (file == null)
        return;
    ISearchQuery[] queries = NewSearchUI.getQueries();
    for (ISearchQuery query : queries) {
        ISearchResult result = query.getSearchResult();
        if (result instanceof AbstractTextSearchResult) {
            AbstractTextSearchResult textResult = (AbstractTextSearchResult) result;
            IFileMatchAdapter adapter = textResult.getFileMatchAdapter();
            if (adapter != null) {
                Match[] matches = adapter.computeContainedMatches(textResult, file);
                for (Match match : matches) {
                    trackCount[0]++;
                    trackPosition((AbstractTextSearchResult) result, (ITextFileBuffer) buffer, match);
                }
            }
        }
    }
}
Also used : ISearchResult(org.eclipse.search.ui.ISearchResult) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IFileMatchAdapter(org.eclipse.search.ui.text.IFileMatchAdapter) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult) ISearchQuery(org.eclipse.search.ui.ISearchQuery) Match(org.eclipse.search.ui.text.Match)

Example 5 with ISearchQuery

use of org.eclipse.search.ui.ISearchQuery 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)

Aggregations

ISearchQuery (org.eclipse.search.ui.ISearchQuery)30 Test (org.junit.Test)13 AbstractTextSearchResult (org.eclipse.search.ui.text.AbstractTextSearchResult)11 Match (org.eclipse.search.ui.text.Match)11 ISearchResult (org.eclipse.search.ui.ISearchResult)6 IFile (org.eclipse.core.resources.IFile)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 IStatus (org.eclipse.core.runtime.IStatus)2 IQueryListener (org.eclipse.search.ui.IQueryListener)2 ISearchResultListener (org.eclipse.search.ui.ISearchResultListener)2 SearchResultEvent (org.eclipse.search.ui.SearchResultEvent)2 MatchEvent (org.eclipse.search.ui.text.MatchEvent)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1