Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 26826

Summary: Add ability for users to implement a interface.....
Product: [Eclipse Project] JDT Reporter: Jalpesh <jpatadia>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 Keywords: helpwanted
Version: 2.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Jalpesh CLA 2002-11-20 20:55:41 EST
Currently in the JDT UI, when you create a new Class, you have the option to
implement an interface if you choose so. If a user chooses an interface, the
generated class should contain all the methods of that interface. It does not do
that in the M3 build.

Once the class is generated, there should be an option in the outline view
called "Implement Interface" which would open up a Open type dialog asking user
to choose an interface (This should also allow multiple selection of interfaces)
Once the user hits ok, the class should implement this interface with all the
appropriate methods. 

You can do the next step by selecting "Override/Implement Methods......" in the
Source Menu for the current build, but I think the above mentioned way is more
intuitive and saves users a couple of extra steps.

Thanks,
Jalpesh.
Comment 1 Adam Kiezun CLA 2002-11-21 04:20:54 EST
worksforme on M3 - do you have the 'inherited abstract methods' checkbox 
selected?
Comment 2 Dirk Baeumer CLA 2002-11-21 06:09:10 EST
The Implement Interface is a nice idea. But given the current schedule this 
will very likely not happen for 2.1.

Since it is an isolated feature it might be a good third party opportunity. 
Interested ?
Comment 3 Jalpesh CLA 2002-11-21 12:43:26 EST
>> worksforme on M3 - do you have the 'inherited abstract methods' checkbox 
>> selected?

My mistake, you're right I did not have that checkbox clicked. Once I had that
checked, the methods in the interface were generated correctly. On a side note,
I think the naming of this checkbox should be changed to something like "inherit
methods/implement interface" (or add another checkbox for implementing
interfaces) so that it's clear to the user what it'll do. When I looked at the
checkbox, I thought it will be used only for the methods in the class I extend
for and not for the implemented interface.


>> The Implement Interface is a nice idea. But given the current schedule this 
>> will very likely not happen for 2.1.

>> Since it is an isolated feature it might be a good third party opportunity. 
>> Interested ?

Sure, if you can point me to where to change that I'd definately take a look.
I'm not very familiar with SWT (nor I am familiar with the eclipse code base),
but hopefully this shouldn't be too much of a problem.

thanks,
jalpesh.


Thanks,
Jalpesh.
Comment 4 Dirk Baeumer CLA 2002-11-27 03:46:21 EST
A good starting point is the current Override/Implement Methods... code. The 
main entry point is the OverrideMethodsAction. This action then uses the 
AddUnimplementedMethodsOperation to actually add the unimplemented methods. 

An action "ImplementInterfaceAction" could reuse the 
AddUnimplementedMethodsOperation. Beside adding the new method stubs the type 
declaration has to be changed as well so that the class implements the new 
interfaces.
Comment 5 Dirk Baeumer CLA 2003-04-01 12:10:39 EST
Reopening...
Comment 6 Dirk Baeumer CLA 2003-04-01 12:11:59 EST
There are two ways to implement an interface:

- using quick fix
- using Override/Implement methods.

Besides this no further action is planned in Eclipse. But if someone 
contributes the code....