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
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
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.
This did the trick: http://wiki.eclipse.org/FAQ_How_do_I_insert_text_in_the_active_text_editor%3F
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.
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.