Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » XML templates filtering by extension(How to filter XML templates depending on the file being edited?)
XML templates filtering by extension [message #498689] Wed, 18 November 2009 07:18 Go to next message
Csaba Koncz is currently offline Csaba KonczFriend
Messages: 49
Registered: July 2009
Member
Our product uses WST XML Editor for editing two types of XML files (i.e. there are two XML Schemas these documents conform with).
I have also created a number of XML templates that provide meaningful attribute values and XML snippets for these XMLs.

However, the templates are relevant only in one type of XML and not in the other. As the templates are contributed by different plugins, I am wondering whether it is possible to enable/disable the templates depending on the file being edited, so that only the meaningful XML templates are offered to the user?

Best regards,
Csaba
Re: XML templates filtering by extension [message #499502 is a reply to message #498689] Mon, 23 November 2009 03:47 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4430
Registered: July 2009
Senior Member

Csaba Koncz wrote:
> Our product uses WST XML Editor for editing two types of XML files
> (i.e. there are two XML Schemas these documents conform with). I have
> also created a number of XML templates that provide meaningful attribute
> values and XML snippets for these XMLs.
> However, the templates are relevant only in one type of XML and not in
> the other. As the templates are contributed by different plugins, I am
> wondering whether it is possible to enable/disable the templates
> depending on the file being edited, so that only the meaningful XML
> templates are offered to the user?

Yes, but not in the manner you're probably thinking of. If the two
files are separated into to different Content Types
(org.eclipse.core.contenttype.contentTypes extension point) and the
templates into different contexts, the editor will be able to use
two different source viewer configurations for them
( http://www.eclipse.org/webtools/wst/components/sse/designs/E ditorConfiguration.html).
The content assist processors that are used by default can then
choose which template contexts from which to load your templates.

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


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: XML templates filtering by extension [message #500218 is a reply to message #499502] Wed, 25 November 2009 12:32 Go to previous messageGo to next message
Csaba Koncz is currently offline Csaba KonczFriend
Messages: 49
Registered: July 2009
Member
Thank you for your reply, Nitin.

I started off in the direction you pointed out: defined a content type that has org.eclipse.core.runtime.xml as its base type and hooked in my own editor configuration.
After copying XMLContentAssistProcessor and XMLTemplateCompletionProcessor to my package (subclassing these is impossible, either because they use private methods or the class itself is package private) I got access to to code that retrieves the templates from the TemplateStore (getTemplates(contextTypeID) in XMLTemplateCompletionProcessor).

Now what I need is a way of tagging the templates somehow so that I can filter them by the content type. But I see no way to do this - is there any?

Best regards,
Csaba
Re: XML templates filtering by extension [message #501031 is a reply to message #500218] Mon, 30 November 2009 18:17 Go to previous messageGo to next message
David Carver is currently offline David CarverFriend
Messages: 174
Registered: July 2009
Senior Member
You might be interested in taking a look at how the wst.xsl component does it. It creates a new template store for the XPath 1.0 content assistance used during the XSLT content assitance. We also have a template store just for the XSLT templates as well.

We also just recently added a new extension point for contentAssistance so that it was easier for adopters to add their own content assitance to the existing editor.

Take a look at org.eclipse.wst.xsl.ui and org.eclispe.wst.xml.xpath.ui for more examples.
Re: XML templates filtering by extension [message #502230 is a reply to message #501031] Mon, 07 December 2009 10:35 Go to previous messageGo to next message
Csaba Koncz is currently offline Csaba KonczFriend
Messages: 49
Registered: July 2009
Member
Hello Dave,
Thank you for your advice. I checked the plugins you mentioned, but I am still rather confused. First of all, I could not find the extension for plugging content assistors (I have installed xml_ui feature 3.1.0 and xsl.feature 1.0.2 from the Galileo update site).

Then, I saw how templates can be separated using separate template storages. But the different templates still use distinct contexts, e.g. the XSL templates can be defined only for context "xsl_new". What I would expect is the ability to define XSL templates for all XML contexts, so that, for example, the standard copy template would be available also for "xml_tag" (so I can insert the copy template into an existing XSL file).

Further, when defining a ContributionTemplateStore a key is defined for storing the templates. But when contributing templates via the ui.editor.templates extension point there is no way to specify such a key, so the templates will show up in all TemplateStores whose configuration include the template context.

Csaba
Re: XML templates filtering by extension [message #502376 is a reply to message #502230] Mon, 07 December 2009 21:58 Go to previous messageGo to next message
David Carver is currently offline David CarverFriend
Messages: 174
Registered: July 2009
Senior Member
The extension I mentioned will be available in Helios, it isn't available in Galileo.

Re: XML templates filtering by extension [message #502377 is a reply to message #502230] Mon, 07 December 2009 22:00 Go to previous message
David Carver is currently offline David CarverFriend
Messages: 174
Registered: July 2009
Senior Member
Oh and there is an open bug for adding XSL tag templates, that is targeted for 3.2M5. We ran out of time in 3.2M4.
Previous Topic:Issue with Axis2, Tomcat, Spring, and Eclipse working then not working
Next Topic:JSP editor problem
Goto Forum:
  


Current Time: Fri Mar 29 15:45:36 GMT 2024

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

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

Back to the top