Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » New Editor?(Using "template"?)
New Editor? [message #674529] Fri, 27 May 2011 09:20 Go to next message
MarcoGT  is currently offline MarcoGT
Messages: 77
Registered: May 2011
Member
Hi all,

as said I am trying to extend the default XML editors with some features.
Yesterday I downloaded the source code from repositoy "webtools", okay.

But, to start a new project based on the default XML editor shouldn't I create a new Plug-in Development Project and use the Editor template?

I am a little bit confused about this.

Thanks
Marco
(no subject) [message #675639 is a reply to message #674529] Wed, 01 June 2011 04:32 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2308
Registered: July 2009
Senior Member
On 5/27/2011 5:20 AM, MarcoGT wrote:
> as said I am trying to extend the default XML editors with some features.
> Yesterday I downloaded the source code from repositoy "webtools", okay.
>
> But, to start a new project based on the default XML editor shouldn't I
> create a new Plug-in Development Project and use the Editor template?
>
> I am a little bit confused about this.

The default editor template creates A XML Editor, but it's not the same
XML Editor that we provide from WTP (which is considerably more
complicated). The template is a nice and more straightforward way to
examine how the editor class and viewers are used.

So the question really is, what kind of features are you looking to add?
Is this for a different editor, or do you plan to just add some
functionality to the existing XML Editor?

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


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: (no subject) [message #675988 is a reply to message #675639] Thu, 02 June 2011 09:37 Go to previous messageGo to next message
MarcoGT  is currently offline MarcoGT
Messages: 77
Registered: May 2011
Member
Ok, in these days I studied the editor.

I would like to add some features to the content assist, for example.

I tried to start a new plugin project using the template but this has less features than the "default" one, for example no outline, no tag folding and so on.

So, my plan is to check-out sources that build up the standard XML editor and start to implement my features from there.

Is it a good point?
Re: (no subject) [message #676023 is a reply to message #675988] Thu, 02 June 2011 14:29 Go to previous messageGo to next message
Robert Gruendler is currently offline Robert Gruendler
Messages: 66
Registered: June 2011
Member
i'm actually trying a similar thing, except that i would like to extend the html editor to provide syntax highlighting for a templating language which looks like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
  <head>
    <title>My Webpage</title>
  </head>
  <body>
    <ul id="navigation">
    {% for item in navigation %}
      <li><a href="{{ item.href }}">{{ item.caption }}</a></li>
    {% endfor %}
    </ul>

    <h1>My Webpage</h1>
    {{ a_variable }}
  </body>
</html>


What i've found out so far is for that to work i need to do the following:

1. Declare a org.eclipse.wst.sse.core.modelHandler
2. In that ModelHandler, implement "getDocumentLoader()" and return a custom DocumentLoader, which extends "HTMLDocumentLoader".
3. In the DocumentLoader, override "getParser()" and return a custom RegionParser (which in turn extends XMLSourceParser)
4. The SourceParser overrides the "getTokenizer()" method.

I assume that the Tokenizer is responsible for detecting the Tokens in the InputString - which are the tokens of the custom templating grammar.

This is where i'm stuck though. The Tokenizer which is returned by the XMLSourceParser is a XMLTokenizer. From what i could find out, the source code
of the XMLTokenizer has been generated by jflex - from a file like

org.eclipse.wst.sse.core/DevTimeSupport/SedModel/HTMLTokenizer/devel/XMLTokenizer.jflex

My question now is: To add syntax-highlighting for a templating engine which adds non-xml structures to the Document, do i need to specify such a .jflex
grammar and generate the corresponding tokenizer from that "jflex" library?

thanks!

[Updated on: Thu, 02 June 2011 14:36]

Report message to a moderator

Re: (no subject) [message #676025 is a reply to message #676023] Thu, 02 June 2011 14:42 Go to previous messageGo to next message
Robert Gruendler is currently offline Robert Gruendler
Messages: 66
Registered: June 2011
Member
@MarcoGT: i think you should have a look at this project:


code.google.com/p/tapestry4e/


They extend the HTML Editor to add some specific code assist, i think when you read through the sources you can get
a step further.

Re: (no subject) [message #676214 is a reply to message #676025] Fri, 03 June 2011 08:37 Go to previous messageGo to next message
MarcoGT  is currently offline MarcoGT
Messages: 77
Registered: May 2011
Member
I think that "should" be enought to work on the sources that build up the XML editor.

Why do you want to declare a new ModelHandler?
Re: (no subject) [message #676240 is a reply to message #676214] Fri, 03 June 2011 11:06 Go to previous messageGo to next message
Robert Gruendler is currently offline Robert Gruendler
Messages: 66
Registered: June 2011
Member
because the content of the document i'm trying to support contains non-xml structures, like

{ for foo in bar }  ...  { endfor }


which won't be understood by the xml tokenizer, and therefore can't be highlighted.

in your case (if i understand you correctly ) you want to add additional code assist to an existing xml document, which however is still a well-formed XML structure.

that's why i think what you are trying to do is possible with existing extension points (like the one the typestry4e plugin uses). but my use-case is different from that - therefore i created a separate thread, cause i don't want to hijack this one Wink

also, i've found this bug report which explains why it's not possible in a proper way to add additional grammars to existing WTP editors.
Re: (no subject) [message #677215 is a reply to message #675988] Tue, 07 June 2011 20:38 Go to previous message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2308
Registered: July 2009
Senior Member
On 6/2/2011 5:37 AM, MarcoGT wrote:
> Ok, in these days I studied the editor.
>
> I would like to add some features to the content assist, for example.
>
> I tried to start a new plugin project using the template but this has
> less features than the "default" one, for example no outline, no tag
> folding and so on.
>
> So, my plan is to check-out sources that build up the standard XML
> editor and start to implement my features from there.
>
> Is it a good point?

Yes, just be conscious of which branch of CVS you check out from
compared to what version of Eclipse you're working in. HEAD is intended
to be our 3.3 release on top of Eclipse 3.7 while Helios is 3.2.x on top
of Eclipse 3.6.

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


---
Nitin Dahyabhai
Eclipse WTP, IBM
Previous Topic:@XmlSchema for a metro webservice
Next Topic:How to validate XML files without specifying xmlns namespace attribute in the root element?
Goto Forum:
  


Current Time: Tue Oct 21 15:29:03 GMT 2014

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

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