Search in sources :

Example 11 with ISearchQuery

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

the class TestSearchResult method testRemoveMatch.

@Test
public void testRemoveMatch() {
    ISearchQuery query = new NullQuery();
    AbstractTextSearchResult result = (AbstractTextSearchResult) query.getSearchResult();
    // $NON-NLS-1$
    String object = "object";
    Match match1 = new Match(object, 0, 0);
    result.addMatch(match1);
    Match match2 = new Match(object, 0, 0);
    result.addMatch(match2);
    assertEquals(result.getMatchCount(), 2);
    result.removeMatch(match1);
    assertEquals(result.getMatchCount(), 1);
    result.removeMatch(match1);
    assertEquals(result.getMatchCount(), 1);
}
Also used : AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult) ISearchQuery(org.eclipse.search.ui.ISearchQuery) Match(org.eclipse.search.ui.text.Match) Test(org.junit.Test)

Example 12 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 13 with ISearchQuery

use of org.eclipse.search.ui.ISearchQuery in project titan.EclipsePlug-ins by eclipse.

the class LogSearchPage method performAction.

@Override
public boolean performAction() {
    List<IFile> files = collectFilesForSearch();
    LogSearchQuery query = new LogSearchQuery(files, getPattern());
    for (ISearchQuery runningQuery : NewSearchUI.getQueries()) {
        NewSearchUI.cancelQuery(runningQuery);
    }
    NewSearchUI.runQueryInBackground(query);
    return true;
}
Also used : IFile(org.eclipse.core.resources.IFile) LogSearchQuery(org.eclipse.titan.log.viewer.search.LogSearchQuery) ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 14 with ISearchQuery

use of org.eclipse.search.ui.ISearchQuery in project titan.EclipsePlug-ins by eclipse.

the class ReferenceSearch method runAction.

/**
 * Helper function used by FindReferences classes for TTCN-3, ASN.1 and
 * TTCNPP editors
 */
public static void runAction(final IEditorPart targetEditor, final ISelection selection) {
    targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(null);
    IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
    if (file == null) {
        targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(FILENOTIDENTIFIABLE);
        return;
    }
    if (!TITANNature.hasTITANNature(file.getProject())) {
        targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(TITANNature.NO_TITAN_FILE_NATURE_FOUND);
        return;
    }
    IPreferencesService prefs = Platform.getPreferencesService();
    boolean reportDebugInformation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
    int offset;
    if (selection instanceof TextSelection && !selection.isEmpty() && !"".equals(((TextSelection) selection).getText())) {
        if (reportDebugInformation) {
            TITANDebugConsole.println("text selected: " + ((TextSelection) selection).getText());
        }
        TextSelection tSelection = (TextSelection) selection;
        offset = tSelection.getOffset() + tSelection.getLength();
    } else {
        offset = ((IEditorWithCarretOffset) targetEditor).getCarretOffset();
    }
    // find the module
    ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
    if (ResourceExclusionHelper.isExcluded(file)) {
        targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(MessageFormat.format(EXCLUDEDFROMBUILD, file.getFullPath()));
        return;
    }
    final Module module = projectSourceParser.containedModule(file);
    if (module == null) {
        targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(MessageFormat.format(NOTFOUNDMODULE, file.getName()));
        return;
    }
    final ReferenceFinder rf = new ReferenceFinder();
    boolean isDetected = rf.detectAssignmentDataByOffset(module, offset, targetEditor, true, reportDebugInformation);
    if (!isDetected) {
        return;
    }
    final ReferenceSearchQuery query = new ReferenceSearchQuery(rf, module, file.getProject());
    for (ISearchQuery runningQuery : NewSearchUI.getQueries()) {
        NewSearchUI.cancelQuery(runningQuery);
    }
    NewSearchUI.runQueryInBackground(query);
}
Also used : IFile(org.eclipse.core.resources.IFile) ReferenceFinder(org.eclipse.titan.designer.AST.ReferenceFinder) TextSelection(org.eclipse.jface.text.TextSelection) Module(org.eclipse.titan.designer.AST.Module) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser) ISearchQuery(org.eclipse.search.ui.ISearchQuery)

Example 15 with ISearchQuery

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

the class InternalSearchUI method removeAllQueries.

public void removeAllQueries() {
    for (Iterator queries = fSearchJobs.keySet().iterator(); queries.hasNext(); ) {
        ISearchQuery query = (ISearchQuery) queries.next();
        cancelSearch(query);
    }
    fSearchJobs.clear();
    getSearchManager().removeAll();
}
Also used : Iterator(java.util.Iterator) 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