Is there a way to create a Class from Interface?
What I'm looking for is a way (like with Eclipse) that I can create a class that implements an Interface and automatically provides the necessary stub implemenations.
Currnetly I'm having to create the class then type in "implements FooBar" and then use Ctrl-i and choose the methods. It would much nicer if this could all be done automatically upon class creation.
Please sign in to leave a comment.
Rick wrote:
You can visit the interface, click the interface name, press Alt+Enter
and choose "Implement interface." Other than that I think having to type
"implements FooBar" and ctrl+i is a much nicer option than a large "New
class" dialog.
Alt-Enter is perfect! Thanks.
Rick wrote:
You can also download DeclarationsTools plugin. As you created new
class, press ALT-I (or customize it to your favorite shortcut). A dialog
with class name will appear that will let you to select interface.
As soon as you'll select interface, the dialog similar to Implement
interfaces will appear and you'll be able to select methods that should
be overridden.
Plugin will automatically add implements XXX string as well as methods
that should be implemented.
The same functionality should let you extend class too (in later case,
it will insert "extends", of course).
Btw, in the same plugin there is another small tool that let you create
new class from editor - you have to press ALT-N, a small dialog appear
that let you specify name of class, type (class, interface, enum etc)
and package where that class should be located (actually, this
functionality is similar to one used in JBuilder to create new class,
and I've missed it in IDEA). Using that tool, it slightly faster to
create new class (at least for me)
Another small goody from the same plugin - combined implement/override
tool, that allows to implement and override methods from the same dialog.
Regards,
Andrew Sazonov
-
http://www.soft-amis.com
SoftAMIS - Your source of high quality Java and Web solutions.