Search in sources :

Example 26 with ISearchQuery

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

the class InternalSearchUI method removeAllQueries.

public void removeAllQueries() {
    for (ISearchQuery query : fSearchJobs.keySet()) {
        cancelSearch(query);
    }
    fSearchJobs.clear();
    getSearchManager().removeAll();
}
Also used : ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 27 with ISearchQuery

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

the class SearchAgainAction method run.

@Override
public void run() {
    final ISearchResult search = fView.getCurrentSearchResult();
    if (search != null) {
        ISearchQuery query = search.getQuery();
        NewSearchUI.cancelQuery(query);
        if (query.canRerun()) {
            if (query.canRunInBackground())
                NewSearchUI.runQueryInBackground(query, fView);
            else {
                Shell shell = fView.getSite().getShell();
                ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
                IStatus status = NewSearchUI.runQueryInForeground(pmd, query, fView);
                if (!status.isOK() && status.getSeverity() != IStatus.CANCEL) {
                    ErrorDialog.openError(shell, SearchMessages.SearchAgainAction_Error_title, SearchMessages.SearchAgainAction_Error_message, status);
                }
            }
        }
    }
}
Also used : ISearchResult(org.eclipse.search.ui.ISearchResult) Shell(org.eclipse.swt.widgets.Shell) IStatus(org.eclipse.core.runtime.IStatus) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 28 with ISearchQuery

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

the class SearchHistoryDropDownAction method getMenu.

@Override
public Menu getMenu(Control parent) {
    ISearchResult currentSearch = fSearchView.getCurrentSearchResult();
    disposeMenu();
    fMenu = new Menu(parent);
    ISearchQuery[] searches = NewSearchUI.getQueries();
    if (searches.length > 0) {
        for (ISearchQuery search : searches) {
            ISearchResult searchResult = search.getSearchResult();
            ShowSearchFromHistoryAction action = new ShowSearchFromHistoryAction(searchResult);
            action.setChecked(searchResult.equals(currentSearch));
            addActionToMenu(fMenu, action);
        }
        new MenuItem(fMenu, SWT.SEPARATOR);
        addActionToMenu(fMenu, new ShowSearchHistoryDialogAction(fSearchView));
        addActionToMenu(fMenu, new RemoveAllSearchesAction());
    }
    return fMenu;
}
Also used : ISearchResult(org.eclipse.search.ui.ISearchResult) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 29 with ISearchQuery

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

the class SearchHistorySelectionDialog method okPressed.

/*
	 * Overrides method from Dialog
	 */
@Override
protected void okPressed() {
    // Build a list of selected children.
    ISelection selection = fViewer.getSelection();
    if (selection instanceof IStructuredSelection)
        setResult(((IStructuredSelection) fViewer.getSelection()).toList());
    // remove queries
    for (ISearchResult result : fRemovedEntries) {
        ISearchQuery query = result.getQuery();
        if (query != null) {
            // must not be null: invalid implementation of a search query
            InternalSearchUI.getInstance().removeQuery(query);
        }
    }
    super.okPressed();
}
Also used : ISearchResult(org.eclipse.search.ui.ISearchResult) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 30 with ISearchQuery

use of org.eclipse.search.ui.ISearchQuery in project webtools.sourceediting by eclipse.

the class FindOccurrencesProcessor method findOccurrences.

public boolean findOccurrences(IDocument document, ITextSelection textSelection, IFile file) {
    boolean findOccurrences = false;
    // determine if action should be enabled or not
    if (document instanceof IStructuredDocument) {
        IStructuredDocument structuredDocument = (IStructuredDocument) document;
        IStructuredDocumentRegion sdRegion = structuredDocument.getRegionAtCharacterOffset(textSelection.getOffset());
        if (sdRegion != null) {
            ITextRegion r = sdRegion.getRegionAtCharacterOffset(textSelection.getOffset());
            if (r != null) {
                String type = r.getType();
                if (enabledForRegionType(type)) {
                    String matchText = sdRegion.getText(r);
                    // first of all activate the view
                    NewSearchUI.activateSearchResultView();
                    if (matchText != null && type != null) {
                        ISearchQuery searchQuery = getSearchQuery(file, structuredDocument, matchText, type, textSelection);
                        if (searchQuery != null) {
                            if (searchQuery.canRunInBackground())
                                NewSearchUI.runQueryInBackground(searchQuery);
                            else
                                NewSearchUI.runQueryInForeground(null, searchQuery);
                        }
                        findOccurrences = true;
                    }
                }
            }
        }
    }
    return findOccurrences;
}
Also used : IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) 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