Search in sources :

Example 1 with WorkingSetSearchScope

use of org.eclipse.wst.common.core.search.scope.WorkingSetSearchScope in project webtools.sourceediting by eclipse.

the class FindReferencesInWorkingSetAction method run.

public void run() {
    IWorkingSet[] workingSets = queryWorkingSets();
    if (workingSets == null || workingSets.length == 0)
        // The user chooses nothing, no point to continue.
        return;
    String pattern = "";
    XSDNamedComponent component = getXSDNamedComponent();
    IFile file = getCurrentFile();
    if (file != null && component != null) {
        QualifiedName metaName = determineMetaName(component);
        QualifiedName elementQName = new QualifiedName(component.getTargetNamespace(), component.getName());
        // Create a scope from the selected working sets
        WorkingSetSearchScope scope = new WorkingSetSearchScope();
        for (int i = 0; i < workingSets.length; i++) {
            IAdaptable[] elements = workingSets[i].getElements();
            scope.addAWorkingSetToScope(elements);
        }
        String scopeDescription = "Working Set";
        XSDSearchQuery searchQuery = new XSDSearchQuery(pattern, file, elementQName, metaName, XSDSearchQuery.LIMIT_TO_REFERENCES, scope, scopeDescription);
        NewSearchUI.activateSearchResultView();
        NewSearchUI.runQueryInBackground(searchQuery);
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) IFile(org.eclipse.core.resources.IFile) WorkingSetSearchScope(org.eclipse.wst.common.core.search.scope.WorkingSetSearchScope) QualifiedName(org.eclipse.wst.common.core.search.pattern.QualifiedName) IWorkingSet(org.eclipse.ui.IWorkingSet) XSDSearchQuery(org.eclipse.wst.xsd.ui.internal.search.XSDSearchQuery)

Aggregations

IFile (org.eclipse.core.resources.IFile)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IWorkingSet (org.eclipse.ui.IWorkingSet)1 QualifiedName (org.eclipse.wst.common.core.search.pattern.QualifiedName)1 WorkingSetSearchScope (org.eclipse.wst.common.core.search.scope.WorkingSetSearchScope)1 XSDSearchQuery (org.eclipse.wst.xsd.ui.internal.search.XSDSearchQuery)1 XSDNamedComponent (org.eclipse.xsd.XSDNamedComponent)1