1 11 package org.eclipse.jdt.ui.actions; 12 13 import org.eclipse.ui.IWorkbenchSite; 14 import org.eclipse.ui.IWorkingSet; 15 import org.eclipse.ui.PlatformUI; 16 17 import org.eclipse.jdt.core.IJavaElement; 18 import org.eclipse.jdt.core.JavaModelException; 19 import org.eclipse.jdt.core.search.IJavaSearchScope; 20 21 import org.eclipse.jdt.ui.search.ElementQuerySpecification; 22 import org.eclipse.jdt.ui.search.QuerySpecification; 23 24 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 25 import org.eclipse.jdt.internal.ui.JavaPluginImages; 26 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; 27 import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory; 28 import org.eclipse.jdt.internal.ui.search.SearchMessages; 29 import org.eclipse.jdt.internal.ui.search.SearchUtil; 30 31 41 public class FindDeclarationsInWorkingSetAction extends FindDeclarationsAction { 42 43 private IWorkingSet[] fWorkingSet; 44 45 53 public FindDeclarationsInWorkingSetAction(IWorkbenchSite site) { 54 this(site, null); 55 } 56 57 65 public FindDeclarationsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets) { 66 super(site); 67 fWorkingSet= workingSets; 68 } 69 70 74 public FindDeclarationsInWorkingSetAction(JavaEditor editor) { 75 this(editor, null); 76 } 77 78 84 public FindDeclarationsInWorkingSetAction(JavaEditor editor, IWorkingSet[] workingSets) { 85 super(editor); 86 fWorkingSet= workingSets; 87 } 88 89 void init() { 90 setText(SearchMessages.Search_FindDeclarationsInWorkingSetAction_label); 91 setToolTipText(SearchMessages.Search_FindDeclarationsInWorkingSetAction_tooltip); 92 setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_DECL); 93 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_DECLARATIONS_IN_WORKING_SET_ACTION); 94 } 95 96 QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException { 97 JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); 98 99 IWorkingSet[] workingSets= fWorkingSet; 100 if (fWorkingSet == null) { 101 workingSets= factory.queryWorkingSets(); 102 if (workingSets == null) 103 return null; 104 } 105 SearchUtil.updateLRUWorkingSets(workingSets); 106 IJavaSearchScope scope= factory.createJavaSearchScope(workingSets, true); 107 String description= factory.getWorkingSetScopeDescription(workingSets, true); 108 return new ElementQuerySpecification(element, getLimitTo(), scope, description); 109 } 110 111 } 112 | Popular Tags |