views:

87

answers:

3

I would like to create a functionality ( for myself ), wherein on clicking a button ( or say firing any event or anything that can trigger my program ), a popup will be displayed which will ask the name of the Class, objects it have and few more thing. Then on pressing OK, it will create a java file with skeleton of predefined methods, inherit known interface and ...

So, basically how to do that? Do i need to create a plugin for eclipse or there is something else in eclipse for it.

PS Please change the title. I am unable to think of any better one.

+2  A: 

You more or less want to add your own wizzard to the 'new class' dialog .. right?

This was the first site I found when typing "creating your own new wizzard eclipse" in Google: http://www.eclipse.org/articles/article.php?file=Article-JFaceWizards/index.html

I don't think this is a correct answer. OP wants to have a new wizard creation for creating new (probably specific) class. So the solution should at least extends the available new class wizard.
nanda
@nanda I agree. This link is just about creating a wizard (first part of the question), not about creating a java source file (second part of the question).
Barthelemy
it seems promising
Rakesh Juyal
A: 

I may be mis-understanding the question, but it sounds like you are re-implementing the New Class Wizard that exists already.

It lets you name the class, the containing package. Can assign a superclass and/or interface and can also choose if you want to include the contructors for the superclass.

A new .java file is created with all known methods from declared interfaces and also any abstract methods from the superclass.

Edt: Title was changed whilst I was writing this reply to "How to creat a customer 'new class wizard; for Eclipse". It makes my answer slightly redundant but I'm not seeing any new functionality being added in the question.

Kevin D
A: 

As others said, you want to create a wizard, then you want to augment the New Class Wizard, which is doing something similar to what you want (but the default wizard don't allow you to to add fields and custom methods).

To create a wizard, you can use the "New File Wizard" extension template: Create a plug-in, then, go to the extensions tab, select Add..., and select the "Extension Wizards" tab. That will get you started on Eclipse wizards.

Once you've learned the basics of creating Wizards and pages, then, include the org.eclipse.jdt.ui and org.eclipse.jdt.core in your plug-in dependencies. Open the following type (Ctrl-Shift-T): "NewClassWizardPage". This is the page that is displayed when you select New > Class in the Package Explorer.

You can probably either copy this page and the parent pages to help you get started or just extend it (in my experience, internal Eclipse wizards such as this one are difficult to extend because they have lots of fields and methods that are package/private, so I usually end up copying the code as a starting point... don't forget to keep the license though!).

Barthelemy