How to change the context of a file template?
Hi,
I added file templates to my plugin using the fileTemplateGroup extension in plugin.xml. I can see my template under the J2EE tab in "Settings" > "File templates", but I can't find how to actually use these templates. In my sandbox, I only get Java Class, File, Package and HTML File. The online doc says that the content of this menu depends on the actual context (in a file, a package etc). My template should be available in packages, how come I can't see it?
Also, what is the difference between templates in the "Templates" tab and in the "Java EE" tab (other than the ability to group templates)?
Please sign in to leave a comment.
The templates in the "Java EE" tab are never directly displayed in the "New" menu. They're only used by specific actions that reference them explicitly.
I got it working by simply dropping my template in the "fileTemplates" directory, and now I get it in my contextual menu.
I looked at existing templates, for example "JavaScript File", which is defined as an internal template. I tried to reproduce this but it does not show up in the contextual menu. Are those internal templates like Java EE templates, i.e. only used by actions?
No, the "JavaScript File" is a regular file template.
If you have a file template that has a .java extension, it will not show up in the menu as a separate item, but it will appear as a choice in the "Kind" combobox of the "New Java Class" action.
Thanks for your answer Dmitry.
That's weird, I can see a file named fileTemplates\internal\JavaScript File.js.ft, and it is also declared as an internalFileTemplate in plugin.xml...
What are those internal templates used for?