Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Create an editor who extend the HTML WTP editor
Create an editor who extend the HTML WTP editor [message #228286] Tue, 24 February 2009 14:47 Go to next message
Alain Sahli is currently offline Alain Sahli
Messages: 19
Registered: July 2009
Junior Member
Hi,

I want to create an editor for template programming. The templates are
composed of HTML and template operators. I want to use the existing HTML
editor from the WTP plugin and extend it to recognize this template
operators.

If I create a new Editor I don't understand how to couple him with the wtp
html editor. I tried to do this :

plugin.xml :

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.core.runtime.contentTypes">
<content-type
file-extensions="tpl"
priority="high"
name="Template"
id="ch.wess.editors.template"
base-type="org.eclipse.wst.html.core.htmlsource"/>
</extension>

<extension
id="test.editors.XMLEditor"
point="org.eclipse.ui.editors">
<editor
name="TPL Editor"
extensions="tpl"
icon="icons/sample.gif"

contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor "
class="ch.wess.editors.TPLEditor"
id="ch.wess.editors.TPLEditor">
</editor>
</extension>

<extension
id="ch.wess.empty.Configuration"
name="TPL Configuration"
point="org.eclipse.wst.sse.ui.editorConfiguration">
<sourceViewerConfiguration
class="ch.wess.editors.TPLViewerConfiguration"
target="ch.wess.editors.template">
</sourceViewerConfiguration>
</extension>
</plugin>

But my class TPLViewerConfiguration is never called.

My question is what is the right way to do this ?

Thanks for your help !

Alain
Re: Create an editor who extend the HTML WTP editor [message #228323 is a reply to message #228286] Wed, 25 February 2009 15:24 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2310
Registered: July 2009
Senior Member
Alain Sahli wrote:
> I want to create an editor for template programming. The templates are
> composed of HTML and template operators. I want to use the existing HTML
> editor from the WTP plugin and extend it to recognize this template
> operators.
>
> If I create a new Editor I don't understand how to couple him with the
> wtp html editor. I tried to do this :
>
> plugin.xml :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?eclipse version="3.2"?>
> <plugin>
> <extension
> point="org.eclipse.core.runtime.contentTypes">
> <content-type
> file-extensions="tpl"
> priority="high"
> name="Template"
> id="ch.wess.editors.template"
> base-type="org.eclipse.wst.html.core.htmlsource"/>
> </extension>

The earlier thread, "Custom Outline View for HTML files", is worth
reading, but I think you've misunderstood how the value of the id
attribute is treated in this element.

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


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: Create an editor who extend the HTML WTP editor [message #228349 is a reply to message #228323] Wed, 25 February 2009 19:40 Go to previous messageGo to next message
Alain Sahli is currently offline Alain Sahli
Messages: 19
Registered: July 2009
Junior Member
Hi Nitin,

Thanks for your answer.

I read all the mails in the thread "Custom Outline View for HTML files".
But it helped me not enough :-)

Today I did another test. I did a very simple plugin with only two
classes. The Activator class and a StructuredTextViewerConfigurationTPL
class which extends StructuredTextViewerConfigurationHTML. And in my
plugin.xml I put :

<extension
point="org.eclipse.wst.sse.ui.editorConfiguration">
<sourceViewerConfiguration
class="confTest.editor.StructuredTextViewerConfigurationTPL "
target="org.eclipse.wst.html.core.htmlsource.source"/>
</extension>

This works perfectly, when I open a file with the HTML editor my TPL
configuration is called. But now I want that my configuration class is
only called when the file extension is *.tpl. So I tried to create a new
contentType but it doesn't work :-( Here's the definition of my
contentType :

<extension
point="org.eclipse.core.runtime.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.xml"
default-charset="UTF-8"
file-extensions="tpl"
id="confTest.template"
name="Template"
priority="high">
<describer
class=" org.eclipse.core.runtime.content.XMLRootElementContentDescri ber2 ">
<parameter name="element" value="elementRacine" />
</describer>
</content-type>
</extension>

<extension
point="org.eclipse.wst.sse.ui.editorConfiguration">
<sourceViewerConfiguration
class="confTest.editor.StructuredTextViewerConfigurationTPL "
target="confTest.template"/>
</extension>

Thanks four your help !
Re: Create an editor who extend the HTML WTP editor [message #228374 is a reply to message #228349] Thu, 26 February 2009 02:13 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2310
Registered: July 2009
Senior Member
You'll notice that the HTML content type ID is defined in
org.eclipse.wst.html.core with an id value of "htmlsource",
resulting in a final ID of org.eclipse.wst.html.core.htmlsource.
Odds are you need to change the ID you're referring to in your
plugin.xml.

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


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: Create an editor who extend the HTML WTP editor [message #228404 is a reply to message #228374] Thu, 26 February 2009 13:13 Go to previous messageGo to next message
Alain Sahli is currently offline Alain Sahli
Messages: 19
Registered: July 2009
Junior Member
I found the solution :

<extension
point="org.eclipse.core.runtime.contentTypes">
<content-type
base-type="org.eclipse.wst.html.core.htmlsource"
default-charset="UTF-8"
file-extensions="tpl"
id="confTest.template"
name="Template"
priority="high">
<describer
class=" org.eclipse.core.runtime.content.XMLRootElementContentDescri ber2 ">
<parameter name="element" value="html" />
</describer>
</content-type>
</extension>

Thanks for your help !
Re: Create an editor who extend the HTML WTP editor [message #228624 is a reply to message #228404] Tue, 03 March 2009 15:16 Go to previous messageGo to next message
Alain Sahli is currently offline Alain Sahli
Messages: 19
Registered: July 2009
Junior Member
Hi !

I have some questions about syntax highlighting. I used the
editorConfiguration extension point and I extended the
StructuredTextViewerConfigurationHTML.

When I open a file with .tpl extension the HTML code is highlighted. This
is ok, but now I want to add syntax highlighting for template operators
who are in HTML code. A template operator looks like this : {operator
parm1=value1 param2=value2 etc...}, a comment : {* Comment *} and a
variable : {$variable}. Is this hard to add a partitioner who recognize
region between "{" and "}" ? And how do I do this ?

I never found where in my configuration I can add partitionType and rules
to recognize it.

Thanks for help!
Re: Create an editor who extend the HTML WTP editor [message #228657 is a reply to message #228624] Fri, 06 March 2009 09:57 Go to previous messageGo to next message
Alain Sahli is currently offline Alain Sahli
Messages: 19
Registered: July 2009
Junior Member
Please, I really need help. Is there a way to add more partition ? Because
in my function getLineStyleProviders(ISourceViewer sourceViewer, String
partitionType) I need to add 3 partition types... How can I do this ?

Thanks :D
Re: Create an editor who extend the HTML WTP editor [message #228664 is a reply to message #228657] Fri, 06 March 2009 17:07 Go to previous messageGo to next message
Eclipse User
Originally posted by: dcarver.starstandard.org

It's not really easy to do. The problem is that much of this is
controled through the SourceParser that the SSE framework uses.

In order to add these extra partitions you basically need to modify a
lot of internal code.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=225994

The above bug is related to what you want to do.

Dave

Alain Sahli wrote:
> Please, I really need help. Is there a way to add more partition ?
> Because in my function getLineStyleProviders(ISourceViewer sourceViewer,
> String partitionType) I need to add 3 partition types... How can I do
> this ?
>
> Thanks :D
>
Re: Create an editor who extend the HTML WTP editor [message #228694 is a reply to message #228664] Fri, 06 March 2009 19:41 Go to previous message
Alain Sahli is currently offline Alain Sahli
Messages: 19
Registered: July 2009
Junior Member
Ok thanks, I definitly give up ! I will do my own editor :-(
Previous Topic:Eclipse won't start up after update
Next Topic:Newbie: publishing a file to a tomcat server
Goto Forum:
  


Current Time: Thu Oct 23 05:23:20 GMT 2014

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

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