Use an XML Template when creating a New XML File [message #322475] |
Mon, 19 November 2007 13:30  |
Eclipse User |
|
|
|
Hi,
Would really appreciate some help here in case I'm way off track.
What I am trying to do is define an XML template and when I create a new
file, that this template gets used in the creation.
I have my org.eclipse.ui.editors.templates extension and this seems fine
and shows up in the WST XML Template store.
What I am trying to figure out now is how this should get used when I
create the file from my New File Wizard.
I can query and get the template, etc but I'm a bit confused then as to
how to go about doing the replace of some of the TemplateVariables, well
mainly if I was heading in the right direction, etc..
Thanks in advance.
Ronan
|
|
|
|
|
Re: Use an XML Template when creating a New XML File [message #322593 is a reply to message #322515] |
Wed, 21 November 2007 04:16  |
Eclipse User |
|
|
|
Ronan Mulvaney wrote:
> Hi Dani,
>
> The Wizard I'm using is just my own creation/extension to the New File
> option to allow for the creation of the file type that I am handling.
> I wasn't aware that they were only code templates,
I guess we should first define the terms ;-)
There are two kinds of JDT templates: the ones used when typing (see
Java > Editor > Templates) and which can be contributed via the
extension point and those that are used when JDT generates code (see
Java > Code Style > Code Templates). Both use the TemplateStore
technology. Now, since you write your own stuff you could use the
extension point to contribute the templates but then, other plug-ins
could theoretically contribute their own code generation tempalates
which would then appear on your preference page (you will have to
provide a Code Templates preference page where users can edit your
default templates. I would therefore suggest to follow the same pattern
as JDT does: use the template store technology but provide your own set
of default templates directly.
For a start take a look at:
org.eclipse.jdt.internal.ui.JavaPlugin.getCodeTemplateStore( )
/org.eclipse.jdt.ui/templates/default-codetemplates.xml
HTH
Dani
> I was hoping to re-use this Template Store to allow developers of my
> artifact the ability to customize the initial file creation similar to
> the "New Java Files" template in the JDT.
>
> Ronan
>
>> Ronan Mulvaney wrote:
>>
>>> Hi,
>>>
>>> Would really appreciate some help here in case I'm way off track.
>>>
>>> What I am trying to do is define an XML template and when I create a
>>> new file, that this template gets used in the creation.
>>>
>>> I have my org.eclipse.ui.editors.templates extension and this seems
>>> fine and shows up in the WST XML Template store.
>>> What I am trying to figure out now is how this should get used when
>>> I create the file from my New File Wizard.
>>
>>
>> Can't speak for XML and have no clue which wizard you're using but
>> normally the templates contributed via the mentioned extension are
>> editor templates used when typing and not code templates used for
>> code generation.
>>
>> Dani
>>
>>> I can query and get the template, etc but I'm a bit confused then as
>>> to how to go about doing the replace of some of the
>>> TemplateVariables, well mainly if I was heading in the right
>>> direction, etc..
>>>
>>> Thanks in advance.
>>>
>>> Ronan
>>
|
|
|
Powered by
FUDForum. Page generated in 0.24330 seconds