1 11 package org.eclipse.jdt.ui.actions; 12 13 import org.eclipse.ui.IWorkbenchSite; 14 import org.eclipse.ui.PlatformUI; 15 16 import org.eclipse.jdt.core.ICompilationUnit; 17 import org.eclipse.jdt.core.IJavaElement; 18 import org.eclipse.jdt.core.IType; 19 import org.eclipse.jdt.core.JavaModelException; 20 import org.eclipse.jdt.core.search.IJavaSearchConstants; 21 22 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 23 import org.eclipse.jdt.internal.ui.JavaPluginImages; 24 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; 25 import org.eclipse.jdt.internal.ui.search.SearchMessages; 26 27 37 public class FindImplementorsAction extends FindAction { 38 39 46 public FindImplementorsAction(IWorkbenchSite site) { 47 super(site); 48 } 49 50 54 public FindImplementorsAction(JavaEditor editor) { 55 super(editor); 56 } 57 58 void init() { 59 setText(SearchMessages.Search_FindImplementorsAction_label); 60 setToolTipText(SearchMessages.Search_FindImplementorsAction_tooltip); 61 setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_DECL); 62 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_IMPLEMENTORS_IN_WORKSPACE_ACTION); 63 } 64 65 Class [] getValidTypes() { 66 return new Class [] { ICompilationUnit.class, IType.class}; 67 } 68 69 boolean canOperateOn(IJavaElement element) { 70 if (!super.canOperateOn(element)) 71 return false; 72 73 if (element.getElementType() == IJavaElement.TYPE) 74 try { 75 return ((IType) element).isInterface(); 76 } catch (JavaModelException ex) { 77 return false; 78 } 79 return false; 81 } 82 83 int getLimitTo() { 84 return IJavaSearchConstants.IMPLEMENTORS; 85 } 86 87 String getOperationUnavailableMessage() { 88 return SearchMessages.JavaElementAction_operationUnavailable_interface; 89 } 90 } 91 92 | Popular Tags |