Search in sources :

Example 6 with FindOccurrencesProcessor

use of org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor in project webtools.sourceediting by eclipse.

the class FindOccurrencesHandler method getProcessorForCurrentSelection.

/**
 * Get the appropriate find occurrences processor
 *
 * @param document -
 *            assumes not null
 * @param textSelection
 * @return
 */
private FindOccurrencesProcessor getProcessorForCurrentSelection(IDocument document, ITextSelection textSelection) {
    // check if we have an action that's enabled on the current partition
    ITypedRegion tr = getPartition(document, textSelection);
    // $NON-NLS-1$
    String partition = tr != null ? tr.getType() : "";
    Iterator it = getProcessors().iterator();
    FindOccurrencesProcessor processor = null;
    while (it.hasNext()) {
        processor = (FindOccurrencesProcessor) it.next();
        // we just choose the first action that can handle the partition
        if (processor.enabledForParitition(partition))
            return processor;
    }
    List extendedFindOccurrencesProcessors = ExtendedConfigurationBuilder.getInstance().getConfigurations(FindOccurrencesProcessor.class.getName(), partition);
    for (int i = 0; i < extendedFindOccurrencesProcessors.size(); i++) {
        Object o = extendedFindOccurrencesProcessors.get(i);
        if (o instanceof FindOccurrencesProcessor) {
            /*
				 * We just choose the first registered processor that
				 * explicitly says it can handle the partition
				 */
            processor = (FindOccurrencesProcessor) o;
            if (processor.enabledForParitition(partition))
                return processor;
        }
    }
    return null;
}
Also used : Iterator(java.util.Iterator) FindOccurrencesProcessor(org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor) ITypedRegion(org.eclipse.jface.text.ITypedRegion) List(java.util.List)

Aggregations

FindOccurrencesProcessor (org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor)6 Iterator (java.util.Iterator)3 List (java.util.List)3 IFile (org.eclipse.core.resources.IFile)3 IDocument (org.eclipse.jface.text.IDocument)3 ITextSelection (org.eclipse.jface.text.ITextSelection)3 ITypedRegion (org.eclipse.jface.text.ITypedRegion)3 IEditorPart (org.eclipse.ui.IEditorPart)3 IFileEditorInput (org.eclipse.ui.IFileEditorInput)3 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)3 StructuredTextEditor (org.eclipse.wst.sse.ui.StructuredTextEditor)3 ArrayList (java.util.ArrayList)2 HTMLFindOccurrencesProcessor (org.eclipse.wst.html.ui.internal.search.HTMLFindOccurrencesProcessor)2 XMLFindOccurrencesProcessor (org.eclipse.wst.xml.ui.internal.search.XMLFindOccurrencesProcessor)2