Search in sources :

Example 31 with AbstractTextSearchResult

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

the class PositionTrackerTest method testInsertAt0.

@Test
public void testInsertAt0() throws Exception {
    NewSearchUI.runQueryInForeground(null, fQuery1);
    AbstractTextSearchResult result = (AbstractTextSearchResult) fQuery1.getSearchResult();
    Object[] elements = result.getElements();
    try {
        for (int i = 0; i < elements.length; i++) {
            checkInsertAtZero(result, (IFile) elements[i]);
        }
    } finally {
        SearchPlugin.getActivePage().closeAllEditors(false);
    }
}
Also used : AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult) Test(org.junit.Test)

Example 32 with AbstractTextSearchResult

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

the class ResultUpdaterTest method testRemoveProject.

@Test
public void testRemoveProject() throws Exception {
    NewSearchUI.runQueryInForeground(null, fQuery1);
    AbstractTextSearchResult result = (AbstractTextSearchResult) fQuery1.getSearchResult();
    ResourceHelper.delete(fProject);
    assertEquals(0, result.getMatchCount());
}
Also used : AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult) Test(org.junit.Test)

Example 33 with AbstractTextSearchResult

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

the class SearchResultPageTest method testRemoveTreeMatches.

@Test
// checkElementDisplay(..) misses cases where one line contains multiple matches
@Ignore
public void testRemoveTreeMatches() throws Exception {
    NewSearchUI.runQueryInForeground(null, fQuery1);
    ISearchResultViewPart view = NewSearchUI.getSearchResultView();
    FileSearchPage page = (FileSearchPage) view.getActivePage();
    page.setLayout(AbstractTextSearchViewPage.FLAG_LAYOUT_TREE);
    AbstractTreeViewer viewer = (AbstractTreeViewer) page.getViewer();
    AbstractTextSearchResult result = (AbstractTextSearchResult) fQuery1.getSearchResult();
    // make sure all elements have items.
    viewer.expandAll();
    Object[] elements = result.getElements();
    // page.setUpdateTracing(true);
    for (int i = 0; i < elements.length; i++) {
        Match[] matches = result.getMatches(elements[i]);
        viewer.reveal(elements[i]);
        for (int j = 0; j < matches.length; j++) {
            checkElementDisplay(viewer, result, elements[i]);
            result.removeMatch(matches[j]);
            consumeEvents(page);
        }
    }
// page.setUpdateTracing(false);
}
Also used : ISearchResultViewPart(org.eclipse.search.ui.ISearchResultViewPart) FileSearchPage(org.eclipse.search.internal.ui.text.FileSearchPage) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult) Match(org.eclipse.search.ui.text.Match) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 34 with AbstractTextSearchResult

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

the class MatchFilterAction method run.

@Override
public void run() {
    AbstractTextSearchResult input = fPage.getInput();
    if (input == null) {
        return;
    }
    ArrayList<MatchFilter> newFilters = new ArrayList<>();
    MatchFilter[] activeMatchFilters = input.getActiveMatchFilters();
    if (activeMatchFilters == null) {
        return;
    }
    for (int i = 0; i < activeMatchFilters.length; i++) {
        if (!activeMatchFilters[i].equals(fFilter)) {
            newFilters.add(activeMatchFilters[i]);
        }
    }
    boolean newState = isChecked();
    if (newState) {
        newFilters.add(fFilter);
    }
    input.setActiveMatchFilters(newFilters.toArray(new MatchFilter[newFilters.size()]));
}
Also used : MatchFilter(org.eclipse.search.ui.text.MatchFilter) ArrayList(java.util.ArrayList) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult)

Example 35 with AbstractTextSearchResult

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

the class MatchFilterSelectionAction method run.

@Override
public void run() {
    Shell shell = fPage.getSite().getShell();
    AbstractTextSearchResult input = fPage.getInput();
    if (input == null) {
        return;
    }
    MatchFilter[] allFilters = input.getAllMatchFilters();
    MatchFilter[] checkedFilters = input.getActiveMatchFilters();
    Integer limit = fPage.getElementLimit();
    boolean enableMatchFilterConfiguration = checkedFilters != null;
    boolean enableLimitConfiguration = limit != null;
    int elementLimit = limit != null ? limit.intValue() : -1;
    MatchFilterSelectionDialog dialog = new MatchFilterSelectionDialog(shell, enableMatchFilterConfiguration, allFilters, checkedFilters, enableLimitConfiguration, elementLimit);
    if (dialog.open() == Window.OK) {
        if (enableMatchFilterConfiguration) {
            input.setActiveMatchFilters(dialog.getMatchFilters());
        }
        if (enableLimitConfiguration) {
            fPage.setElementLimit(Integer.valueOf(dialog.getLimit()));
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MatchFilter(org.eclipse.search.ui.text.MatchFilter) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult)

Aggregations

AbstractTextSearchResult (org.eclipse.search.ui.text.AbstractTextSearchResult)35 Test (org.junit.Test)20 Match (org.eclipse.search.ui.text.Match)19 ISearchQuery (org.eclipse.search.ui.ISearchQuery)11 IFile (org.eclipse.core.resources.IFile)6 Position (org.eclipse.jface.text.Position)6 Annotation (org.eclipse.jface.text.source.Annotation)5 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)5 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)5 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)4 IDocument (org.eclipse.jface.text.IDocument)4 ISearchResult (org.eclipse.search.ui.ISearchResult)4 MatchEvent (org.eclipse.search.ui.text.MatchEvent)4 ArrayList (java.util.ArrayList)3 Pattern (java.util.regex.Pattern)2 BadLocationException (org.eclipse.jface.text.BadLocationException)2 AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)2 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)2 ISearchResultListener (org.eclipse.search.ui.ISearchResultListener)2 SearchResultEvent (org.eclipse.search.ui.SearchResultEvent)2