Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » How To Programmatically Create An HTML File Using The Eclipse Standard HTML Template
How To Programmatically Create An HTML File Using The Eclipse Standard HTML Template [message #233921] Mon, 20 July 2009 21:15 Go to next message
Eclipse UserFriend
Originally posted by: runzhou.li.gmail.com

Hi,

Just like how we can manually add an HTML file in a project with some
prefilled content, how can this be done programmatically?

Thank you in advance.

--
Runzhou Li
Re: How To Programmatically Create An HTML File Using The Eclipse Standard HTML Template [message #234001 is a reply to message #233921] Wed, 22 July 2009 13:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

WTP has a DOM Level 1 implementation that you can use. If you do some
web searches on WTP DOM you should find some tutorials that will show
you how to get a WTP DOM and then use it to add your particular items.

Dave

Runzhou Li wrote:
> Hi,
>
> Just like how we can manually add an HTML file in a project with some
> prefilled content, how can this be done programmatically?
>
> Thank you in advance.
>
> --
> Runzhou Li
>
>
Re: How To Programmatically Create An HTML File Using The Eclipse Standard HTML Template [message #234009 is a reply to message #234001] Wed, 22 July 2009 13:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: runzhou.li.gmail.com

Actually even simpler, can I directly make use of the Eclipse built-in one?
Just want to programmatically call it.

--
Runzhou Li

"David Carver" <dcarver@starstandard.org> wrote in message
news:h473fd$hc2$1@build.eclipse.org...
> WTP has a DOM Level 1 implementation that you can use. If you do some
> web searches on WTP DOM you should find some tutorials that will show you
> how to get a WTP DOM and then use it to add your particular items.
>
> Dave
>
> Runzhou Li wrote:
>> Hi,
>>
>> Just like how we can manually add an HTML file in a project with some
>> prefilled content, how can this be done programmatically?
>>
>> Thank you in advance.
>>
>> --
>> Runzhou Li
Re: How To Programmatically Create An HTML File Using The Eclipse Standard HTML Template [message #234022 is a reply to message #234009] Wed, 22 July 2009 17:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

If you already have a template, you can contribute that template, to the
HTML templates, through the standard Template extension point.

Take a look at the org.eclipse.wst.html.ui plugin.xml for examples.

Dave

Runzhou Li wrote:
> Actually even simpler, can I directly make use of the Eclipse built-in one?
> Just want to programmatically call it.
>
> --
> Runzhou Li
>
> "David Carver" <dcarver@starstandard.org> wrote in message
> news:h473fd$hc2$1@build.eclipse.org...
>> WTP has a DOM Level 1 implementation that you can use. If you do some
>> web searches on WTP DOM you should find some tutorials that will show you
>> how to get a WTP DOM and then use it to add your particular items.
>>
>> Dave
>>
>> Runzhou Li wrote:
>>> Hi,
>>>
>>> Just like how we can manually add an HTML file in a project with some
>>> prefilled content, how can this be done programmatically?
>>>
>>> Thank you in advance.
>>>
>>> --
>>> Runzhou Li
>
>
Re: How To Programmatically Create An HTML File Using The Eclipse Standard HTML Template [message #234122 is a reply to message #234022] Fri, 24 July 2009 13:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: runzhou.li.gmail.com

Hi,

Is there a direct way of getting the template and make use of it? Because I
don't need to have my own template.

Regards,

--
Runzhou Li

"David Carver" <dcarver@starstandard.org> wrote in message
news:4A674D32.5010007@starstandard.org...
> If you already have a template, you can contribute that template, to the
> HTML templates, through the standard Template extension point.
>
> Take a look at the org.eclipse.wst.html.ui plugin.xml for examples.
>
> Dave
>
> Runzhou Li wrote:
>> Actually even simpler, can I directly make use of the Eclipse built-in
>> one? Just want to programmatically call it.
>>
>> --
>> Runzhou Li
>>
>> "David Carver" <dcarver@starstandard.org> wrote in message
>> news:h473fd$hc2$1@build.eclipse.org...
>>> WTP has a DOM Level 1 implementation that you can use. If you do some
>>> web searches on WTP DOM you should find some tutorials that will show
>>> you how to get a WTP DOM and then use it to add your particular items.
>>>
>>> Dave
>>>
>>> Runzhou Li wrote:
>>>> Hi,
>>>>
>>>> Just like how we can manually add an HTML file in a project with some
>>>> prefilled content, how can this be done programmatically?
>>>>
>>>> Thank you in advance.
>>>>
>>>> --
>>>> Runzhou Li
>>
Re: How To Programmatically Create An HTML File Using The Eclipse Standard HTML Template [message #272663 is a reply to message #234122] Mon, 27 July 2009 21:59 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Runzhou Li wrote:
> Is there a direct way of getting the template and make use of it? Because I
> don't need to have my own template.

Yes, but only with internals. We don't guarantee to keep the same
templates and template names from release to release, so it's
recommended you create your own.

TemplateStore templateStore =
HTMLUIPlugin.getDefault().getTemplateStore();
Template template = templateStore.findTemplate(nameOftemplate);
TemplateContextType contextType =
HTMLUIPlugin.getDefault().getTemplateContextRegistry().getCo ntextType(template.getContextTypeId());
IDocument document = new Document();
TemplateContext context = new DocumentTemplateContext(contextType,
document, 0, 0);
TemplateBuffer buffer = context.evaluate(template);
templateString = buffer.getString();

Then you would write the string into a file using IFile.setContents().

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: How To Programmatically Create An HTML File Using The Eclipse Standard HTML Template [message #367698 is a reply to message #272663] Tue, 28 July 2009 14:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: runzhou.li.gmail.com

Thank you so much Nitin.

I'm also trying to avoid using internal classes, so about creating my own
template, say I create a template through
"org.eclipse.ui.editors.templates -> template" called my_html_new but
instead of creating my own contextType, I reuse html_new as contextTypeId.
How can I get access to this template and use it to serve my original
purpose?

"Nitin Dahyabhai" <nitind@us.ibm.com> wrote in message
news:h4l80t$tef$1@build.eclipse.org...
> Runzhou Li wrote:
>> Is there a direct way of getting the template and make use of it? Because
>> I don't need to have my own template.
>
> Yes, but only with internals. We don't guarantee to keep the same
> templates and template names from release to release, so it's recommended
> you create your own.
>
> TemplateStore templateStore =
> HTMLUIPlugin.getDefault().getTemplateStore();
> Template template = templateStore.findTemplate(nameOftemplate);
> TemplateContextType contextType =
> HTMLUIPlugin.getDefault().getTemplateContextRegistry().getCo ntextType(template.getContextTypeId());
> IDocument document = new Document();
> TemplateContext context = new DocumentTemplateContext(contextType,
> document, 0, 0);
> TemplateBuffer buffer = context.evaluate(template);
> templateString = buffer.getString();
>
> Then you would write the string into a file using IFile.setContents().
>
> --
> ---
> Nitin Dahyabhai
> Eclipse WTP Source Editing
> IBM Rational
Re: How To Programmatically Create An HTML File Using The Eclipse Standard HTML Template [message #369116 is a reply to message #367698] Tue, 28 July 2009 17:00 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Runzhou Li wrote:
> I'm also trying to avoid using internal classes, so about creating my own
> template, say I create a template through
> "org.eclipse.ui.editors.templates -> template" called my_html_new but
> instead of creating my own contextType, I reuse html_new as contextTypeId.
> How can I get access to this template and use it to serve my original
> purpose?

Unless you want your template visible in our wizard, content assist,
and preference page, there's no reason to use an HTML context
type--it's perfectly fine to declare your own. I didn't work on
this myself, so there's not a lot of advice I can give past
examining how it's implemented in our plug-ins and those from the
Platform.

One piece of advice I *can* give is to avoid accidentally declaring
the same ID for a context type as anyone else. JSDT has a bug open
due to its contexts colliding with those of JDT (266680), causing
unpredictably incorrect behavior in the preferences UI and content
assist when both are installed.

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: How To Programmatically Create An HTML File Using The Eclipse Standard HTML Template [message #369125 is a reply to message #369116] Tue, 28 July 2009 18:00 Go to previous message
Eclipse UserFriend
Originally posted by: runzhou.li.gmail.com

I see, I'll take a look at how content type is done, and how to make use of
it.

Thank you for your valuable help :)

"Nitin Dahyabhai" <nitind@us.ibm.com> wrote in message
news:h4naqs$j2k$1@build.eclipse.org...
> Runzhou Li wrote:
>> I'm also trying to avoid using internal classes, so about creating my own
>> template, say I create a template through
>> "org.eclipse.ui.editors.templates -> template" called my_html_new but
>> instead of creating my own contextType, I reuse html_new as
>> contextTypeId. How can I get access to this template and use it to serve
>> my original purpose?
>
> Unless you want your template visible in our wizard, content assist, and
> preference page, there's no reason to use an HTML context type--it's
> perfectly fine to declare your own. I didn't work on this myself, so
> there's not a lot of advice I can give past examining how it's implemented
> in our plug-ins and those from the Platform.
>
> One piece of advice I *can* give is to avoid accidentally declaring the
> same ID for a context type as anyone else. JSDT has a bug open due to its
> contexts colliding with those of JDT (266680), causing unpredictably
> incorrect behavior in the preferences UI and content assist when both are
> installed.
>
> --
> ---
> Nitin Dahyabhai
> Eclipse WTP Source Editing
> IBM Rational
Previous Topic:Re: EL support in Eclipse
Next Topic:Facelets Tools Project: can't find faclet tag library
Goto Forum:
  


Current Time: Thu Apr 18 05:06:53 GMT 2024

Powered by FUDForum. Page generated in 0.02249 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top