|Setting contextType for templates [message #649316]
||Tue, 18 January 2011 12:53
| Fredrik Lindqvist
Registered: November 2009
I've run into some problems that I'm not sure how to solve. I'll describe what I want to achieve and then what I have done and tried so far. Hopefully someone can point out where I've gone wrong.|
What I want to achieve:
The user edits an XML file in the WTP XML editor (or any other editor). If my plugin is active, the user should be able to get templates suggested that are relevant for the type of XMLs we use. These templates are linked to three different namespaces and only the templates that are appropriate depending on the current edit position should be shown.
My work so far:
I created three new context types: "org.eclipse.ui.editors.templates" - "contextType". Each context type will correspond to the three namespaces that will be relevant for us. I've added all templates to the extension point "org.eclipse.ui.editors.templates" - "template" and each template is set to one of my contextType.
Now when the user want to get a template I have to determine which contexttype is relevant. This means finding out the namespace where the user is editing.
So I have created a "org.eclipse.wst.sse.ui.completionProposal" - "proposalComputer". The class org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCom pletionProposalComputer looked real nice to reuse, using the right interface and being abstract and all, BUT it is internal and I get "discouraged access" warning. Alot of other classes that would be real useful, like org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistU tils have the same access problem.
With copying several org.eclipse.wst.xml.ui.internal.* classes to my project and hardcoding one of the contexttype, I've been able to get the editor to show the templates, so it is working.
But the discouraged access warning tells me that I'm probably on the wrong path...
Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=310696 atleast tells me I'm not the only one who've run into this issue.
I guess I could create a specific editor that handles our XMLs, but since all we really want are the templates it seems like overkill.
Powered by FUDForum
. Page generated in 0.01518 seconds