Search in sources :

Example 36 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)

Example 37 with AbstractTextSearchResult

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

the class SearchResultLabelProvider method getMatchCountText.

private StyledString getMatchCountText(final Object element) {
    int matchCount = 0;
    final AbstractTextSearchResult result = fPage.getInput();
    if (result != null) {
        matchCount = fPage.getDisplayedMatchCount(element);
    }
    if (matchCount > 1) {
        final String countInfo = MessageFormat.format("({0} matches)", matchCount);
        return new StyledString(countInfo, StyledString.COUNTER_STYLER);
    }
    return new StyledString();
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult)

Aggregations

AbstractTextSearchResult (org.eclipse.search.ui.text.AbstractTextSearchResult)37 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 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)3 Pattern (java.util.regex.Pattern)2 BadLocationException (org.eclipse.jface.text.BadLocationException)2 AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)2 StyledString (org.eclipse.jface.viewers.StyledString)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2