Vishal Pawar
Vishal Pawar

Reputation: 267

Filter classes which implements certain interface using FilteredTypesSelectionDialog

I want to filter all the classes from the workspace which implements certain interface using eclipse jdt FilteredTypesSelectionDialog. Is there any way to achieve this?

IJavaElement[] elements = new IJavaElement[] { javaproject };
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(root.getShell(), false, null, scope, IJavaSearchConstants.CLASS);
//filter classes which implements an interface

Upvotes: 0

Views: 117

Answers (1)

Stephan Herrmann
Stephan Herrmann

Reputation: 8178

For subtypes of a given type use

org.eclipse.jdt.core.search.SearchEngine.createStrictHierarchyScope(IJavaProject, IType, boolean, boolean, WorkingCopyOwner)

To use this in a type selection dialog refer to

org.eclipse.jdt.ui.JavaUI.createTypeDialog(Shell, IRunnableContext, IJavaSearchScope, int, boolean, String, TypeSelectionExtension)

Upvotes: 1

Related Questions