Java Code Examples for org.eclipse.search.ui.text.AbstractTextSearchResult#getElements()

The following examples show how to use org.eclipse.search.ui.text.AbstractTextSearchResult#getElements() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModulaSearchResult.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
public Match[] computeContainedMatches( AbstractTextSearchResult result
                                      , IEditorPart editor ) 
{
    ArrayList<Match> list = new ArrayList<Match>();
    Object[] objects = result.getElements();
    for (int i = 0; i < objects.length; i++) {
        if (objects[i] instanceof IFile) {
            IFile f = (IFile) objects[i];
            if (isMatchContained(editor, f)) {
                Match[] matches = getMatches(f);
                for (int j = 0; j < matches.length; j++) {
                    list.add(matches[j]);
                }
            }
        }
    }
    return (Match[]) list.toArray(new Match[list.size()]);
}
 
Example 2
Source File: TypeScriptSearchTreeContentProvider.java    From typescript.java with MIT License 6 votes vote down vote up
private synchronized void initialize(AbstractTextSearchResult result) {
	fResult= result;
	fChildrenMap= new HashMap();
	boolean showLineMatches= true; //!((TypeScriptSearchQuery) fResult.getQuery()).isFileNameSearch();
	
	if (result != null) {
		Object[] elements= result.getElements();
		for (int i= 0; i < elements.length; i++) {
			if (showLineMatches) {
				Match[] matches= result.getMatches(elements[i]);
				for (int j= 0; j < matches.length; j++) {
					insert(((TypeScriptMatch) matches[j]).getLineElement(), false);
				}
			} else {
				insert(elements[i], false);
			}
		}
	}
}
 
Example 3
Source File: FileTreeContentProvider.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private synchronized void initialize(AbstractTextSearchResult result) {
    fResult = result;
    fChildrenMap = new HashMap<Object, Set>();
    boolean showLineMatches = !((AbstractPythonSearchQuery) fResult.getQuery()).isFileNameSearch();

    if (result != null) {
        Object[] elements = result.getElements();
        for (int i = 0; i < elements.length; i++) {
            if (showLineMatches) {
                Match[] matches = result.getMatches(elements[i]);
                for (int j = 0; j < matches.length; j++) {
                    insert(((FileMatch) matches[j]).getLineElement(), false);
                }
            } else {
                insert(elements[i], false);
            }
        }
    }
}
 
Example 4
Source File: AbstractSearchResultTreePage.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
    fTreeViewer = (TreeViewer) viewer;
    fSearchResult = (AbstractTextSearchResult) newInput;
    resultModel.clearAll();
    if (fSearchResult != null) {
        for (Object o : fSearchResult.getElements()) {
            resultModel.addIFile((IFile)o);
        
        }
    }
    fTreeViewer.refresh();
}
 
Example 5
Source File: LevelTreeContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected synchronized void initialize(AbstractTextSearchResult result) {
	super.initialize(result);
	fChildrenMap= new HashMap<Object, Set<Object>>();
	if (result != null) {
		Object[] elements= result.getElements();
		for (int i= 0; i < elements.length; i++) {
			if (getPage().getDisplayedMatchCount(elements[i]) > 0) {
				insert(null, null, elements[i]);
			}
		}
	}
}
 
Example 6
Source File: AbstractSearchIndexTreeContentProvider.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
    elementToTreeNode.clear();
    if (newInput instanceof AbstractTextSearchResult) {
        AbstractTextSearchResult abstractTextSearchResult = (AbstractTextSearchResult) newInput;
        this.fResult = abstractTextSearchResult;
        root = new TreeNode<>(null, newInput);
        Object[] elements = abstractTextSearchResult.getElements();
        int elementsLen = elements.length;
        for (int i = 0; i < elementsLen; i++) {
            Object object = elements[i];
            Match[] matches = abstractTextSearchResult.getMatches(object);
            int matchesLen = matches.length;
            for (int j = 0; j < matchesLen; j++) {
                Match match = matches[j];
                if (match instanceof ICustomMatch) {
                    ICustomMatch moduleMatch = (ICustomMatch) match;
                    obtainTeeNodeElement(moduleMatch.getLineElement());
                } else {
                    Log.log("Expecting ICustomMatch. Found:" + match.getClass() + " - " + match);
                }
            }
        }
    } else {
        this.clear();
    }
}
 
Example 7
Source File: AbstractSearchIndexResultPage.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public String getLabel() {
    StructuredViewer viewer = getViewer();
    if (viewer instanceof TreeViewer) {
        int count = 0;
        TreeViewer tv = (TreeViewer) viewer;

        final AbstractTextSearchResult input = getInput();
        if (input != null) {
            ViewerFilter[] filters = tv.getFilters();
            if (filters != null && filters.length > 0) {
                Object[] elements = input.getElements();
                for (int j = 0; j < elements.length; j++) {
                    Object element = elements[j];
                    Match[] matches = input.getMatches(element);
                    for (Match match : matches) {
                        for (int i = 0; i < filters.length; i++) {
                            ViewerFilter vf = filters[i];
                            if (vf instanceof AbstractSearchResultsViewerFilter) {
                                AbstractSearchResultsViewerFilter searchResultsViewerFilter = (AbstractSearchResultsViewerFilter) vf;
                                if (searchResultsViewerFilter.isLeafMatch(viewer, match)) {
                                    count += 1;
                                }
                            }
                        }
                    }
                }
            } else {
                // No active filters
                count = input.getMatchCount();
            }
        }
        AbstractTextSearchResult result = getInput();
        if (result == null) {
            return "";
        }
        ISearchQuery query = result.getQuery();
        if (query instanceof AbstractSearchIndexQuery) {
            AbstractSearchIndexQuery searchIndexQuery = (AbstractSearchIndexQuery) query;
            return searchIndexQuery.getResultLabel(count);
        }
    }
    return super.getLabel();
}