Bug 8581 Switch J Search to StructuredContentProvider
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaElementAction.java
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.ui.IWorkingCopyManager;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
/**
 * Abstract class for actions that run on IJavaElement.
 */
public abstract class JavaElementAction extends Action {
	
	
	protected static final IJavaElement RETURN_WITHOUT_BEEP= JavaCore.create(JavaPlugin.getDefault().getWorkspace().getRoot());
	
	private Class[] fValidTypes;
	public JavaElementAction(String label, Class[] validTypes) {
		super(label);
		fValidTypes= validTypes;
	}
	public boolean canOperateOn(ISelection sel) {
		boolean hasSelection= !sel.isEmpty();
		if (!hasSelection || fValidTypes == null)
			return hasSelection;
		if (fValidTypes.length == 0)
			return false;
		IJavaElement element= getJavaElement(sel, true);
		if (element != null) {