views:

64

answers:

4

Hi,

I'm developing an Eclipse plug-in and I'd like to insert code automatically... sort of create a sample application automatically when the user presses a button. How can I go about it please?

Thanks and regards, Krt_Malta

A: 

If you want to create a project/files, then you have to use the Resource API of Eclipse. For some initial ideas look at http://www.phurnace.com/blog/the-eclipse-resources-plug-in-2.html.

In a similar fashion you could look for existing files and read them.

Zoltán Ujhelyi
A: 

A pretty straightforward approach to code generation in Eclipse are Java Emitter Templates. If your use case involves EMF, you could consider Xpand. And there are other options in the Eclipse M2T project.

Fabian Steeg
A: 

This helped me out a lot:

http://sdqweb.ipd.kit.edu/wiki/JDT_Tutorial:_Creating_Eclipse_Java_Projects_Programmatically

Using it you can create projects, packages and classes programatically. With some additional code, you could import libraries into the project files programmatically.

Krt_Malta