Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Interface implementors
Interface implementors [message #220784] Fri, 16 December 2005 13:56 Go to next message
Eclipse UserFriend
Originally posted by: awalkden.alaric.co.uk

Apologies if I've missed an obvious solution, but is there a way of
getting eclipse to present me with all classes in a (java) project that
implement a given interface, or extend a given class? I could ask for
References in the project, but that drags back all objects of that type
that are declared too.
Thanks in advance,
Andrew.
Re: Interface implementors [message #220798 is a reply to message #220784] Fri, 16 December 2005 14:12 Go to previous messageGo to next message
Ricky is currently offline RickyFriend
Messages: 204
Registered: July 2009
Senior Member
> Apologies if I've missed an obvious solution, but is there a way of
> getting eclipse to present me with all classes in a (java) project that
> implement a given interface, or extend a given class?

Try "Open Type Hierarchy" (context menu) or F4 when your cursor is on a
type like a class name.

hth,

Ricky
Re: Interface implementors [message #220805 is a reply to message #220784] Fri, 16 December 2005 14:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: olaf.delgado.web.de

Andrew Walkden wrote:
> Apologies if I've missed an obvious solution, but is there a way of
> getting eclipse to present me with all classes in a (java) project that
> implement a given interface, or extend a given class? I could ask for
> References in the project, but that drags back all objects of that type
> that are declared too.
> Thanks in advance,
> Andrew.

In the Package Explorer, right-click on the class name, then select
"Open Type Hierarchy".

Cheers
O.
Re: Interface implementors [message #220812 is a reply to message #220798] Fri, 16 December 2005 14:41 Go to previous messageGo to next message
Tom Hofmann is currently offline Tom HofmannFriend
Messages: 770
Registered: July 2009
Senior Member
Ricky wrote:
>> Apologies if I've missed an obvious solution, but is there a way of
>> getting eclipse to present me with all classes in a (java) project
>> that implement a given interface, or extend a given class?
>
> Try "Open Type Hierarchy" (context menu) or F4 when your cursor is on a
> type like a class name.

Or, as a lightweight alternative, press Ctrl+T or choose Navigate >
Quick Type Hierarchy, which will open a quick view that you can navigate
through and filter.

-tom
Re: Interface implementors [message #220818 is a reply to message #220812] Fri, 16 December 2005 20:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tonychen.ca.ibm.com

What API should I use to do the same?

Tony

Tom Eicher wrote:
> Ricky wrote:
>
>>> Apologies if I've missed an obvious solution, but is there a way of
>>> getting eclipse to present me with all classes in a (java) project
>>> that implement a given interface, or extend a given class?
>>
>>
>> Try "Open Type Hierarchy" (context menu) or F4 when your cursor is on
>> a type like a class name.
>
>
> Or, as a lightweight alternative, press Ctrl+T or choose Navigate >
> Quick Type Hierarchy, which will open a quick view that you can navigate
> through and filter.
>
> -tom
Re: Interface implementors [message #220824 is a reply to message #220818] Fri, 16 December 2005 22:15 Go to previous messageGo to next message
Andreas Herz is currently offline Andreas HerzFriend
Messages: 196
Registered: July 2009
Senior Member
my solution...

Greetings

Andreas



public static IType[] getAllSubtypes(String superClassName, IJavaProject project,
IProgressMonitor pm) throws Exception
{
IType parentType=project.findType(superClassName);
ITypeHierarchy h=parentType.newTypeHierarchy(project,pm);
IType[] types=h.getAllSubtypes(parentType);
IType[] t2=new IType[types.length+1];
t2[0]=parentType;

return t2;
}
Re: Interface implementors [message #220831 is a reply to message #220824] Fri, 16 December 2005 22:18 Go to previous messageGo to next message
Andreas Herz is currently offline Andreas HerzFriend
Messages: 196
Registered: July 2009
Senior Member
oh - BAD typo during cut&past from my code.

better (?)

public static IType[] getAllSubtypes(String superClassName, IJavaProject
project, IProgressMonitor pm) throws Exception
{
IType parentType=project.findType(superClassName);
ITypeHierarchy h=parentType.newTypeHierarchy(project,pm);
return h.getAllSubtypes(parentType);
}
Re: Interface implementors [message #220955 is a reply to message #220812] Tue, 20 December 2005 21:13 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse3.rizzoweb.com

Tom Eicher wrote:
> Ricky wrote:
>
>>> Apologies if I've missed an obvious solution, but is there a way of
>>> getting eclipse to present me with all classes in a (java) project
>>> that implement a given interface, or extend a given class?
>>
>>
>> Try "Open Type Hierarchy" (context menu) or F4 when your cursor is on
>> a type like a class name.
>
>
> Or, as a lightweight alternative, press Ctrl+T or choose Navigate >
> Quick Type Hierarchy, which will open a quick view that you can navigate
> through and filter.

My preferred method: Right-click on an interface name in the Package
Explorer or Types view and choose Implementors...

You can assign a keyboard shortcut for this action; it is in the Search
category in the Keys preferences.

HTH,
Eric
Previous Topic:type quick fix
Next Topic:Windows Service
Goto Forum:
  


Current Time: Fri Apr 26 22:52:54 GMT 2024

Powered by FUDForum. Page generated in 0.03075 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top