开发者

Programmatically add code templates?

开发者 https://www.devze.com 2023-01-18 22:25 出处:网络
I\'m writing a custom XML editor for our project and want to add support for templates. I.e when the user writes \"<ab:mytag\" and presses ctrl + space they get the option of inserting a chunk of t

I'm writing a custom XML editor for our project and want to add support for templates. I.e when the user writes "<ab:mytag" and presses ctrl + space they get the option of inserting a chunk of text with a default/dummy parameter开发者_开发技巧s.

But this should be available only in the XML editor. How would I go about this?

Clarification: The templates I'm talking about are the ones available when you write for example "syso" in your java editor and press ctrl + space. In preferences you can add your own templates. What I want to do is do define my own templates, for my own XML tags, but I want to do this in the code and have it only effect my editor


After alot of searching I fount this ppt that answered almost all questions I had:

http://www.eclipsecon.org/2008/sub/attachments/Extending_the_XML_and_SSE_editors_from_the_WTP_Project_.ppt

The templates I was after can programatically be added with the use of the extension point org.eclipse.ui.editors.templates


Go to the preferences then XML -> XML Files -> Editor -> Templates. Define your new template there.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号