Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Adding Global Variable
Adding Global Variable [message #446267] Fri, 31 July 2009 21:34 Go to next message
Lon B is currently offline Lon BFriend
Messages: 2
Registered: July 2009
Junior Member
I'd like to create an eclipse plug-in that adds support for a new global
template variable. For instance "user e-mail". I'm easily able to create
a plug-in that adds template variables, but only within specific contexts
(such as 'java' or 'javadoc').

One place in particular where I want to access my new global variable is
within Java > Code Style > Code Templates.

So, I have several questions:

1. Is there some easy way to add the global template variable?

2. Otherwise, via my plug-in, I'm extending the
'org.eclipse.ui.editors.templates' extension point. I set my resolve to a
class that resolves the new variable. However, I must set a
contextTypeId. Again, if I set something like 'java' it works, but then
it's not globally accessible. I can't find any documentation on lists of
available contextTypeIds. I've tried guessing "global", "text", etc. none
seem to work.

Any help would be great appreciated!!

- Lon
Re: Adding Global Variable [message #511903 is a reply to message #446267] Wed, 03 February 2010 11:23 Go to previous messageGo to next message
Volodymýr is currently offline VolodymýrFriend
Messages: 2
Registered: February 2010
Junior Member
Please take a look at the article written by Thomas Wabner on his wordpress. He uses the following method to register resolvers with all context types:

private void registerResolvers() {
  final ContextTypeRegistry codeTemplateContextRegistry = JavaPlugin.getDefault().getCodeTemplateContextRegistry();
  final Iterator ctIter = codeTemplateContextRegistry.contextTypes();
  while (ctIter.hasNext()) {
    final TemplateContextType contextType = (TemplateContextType) ctIter.next();
    contextType.addResolver(new BundleIdResolver());
    contextType.addResolver(new BundleVersionResolver());
  }
}

Andreas Höhmann has found another solution for the similar problem.

I hope this helps Wink
Have a nice day.
Re: Adding Global Variable [message #516781 is a reply to message #446267] Thu, 25 February 2010 07:36 Go to previous messageGo to next message
jefier is currently offline jefierFriend
Messages: 2
Registered: February 2010
Junior Member
Thanks for sharing such a nice sharing.it is very useful for all keep it up.i will come back to see more update.


Get information about oracle certification online now.
Re: Adding Global Variable [message #604497 is a reply to message #446267] Wed, 03 February 2010 11:23 Go to previous messageGo to next message
Volodymýr is currently offline VolodymýrFriend
Messages: 2
Registered: February 2010
Junior Member
Please take a look at the http://thomaswabner.wordpress.com/2009/08/21/use-your-own-va riable-in-eclipse-code-templates/ written by Thomas Wabner on his wordpress. He uses the following method to register resolvers with all context types:


private void registerResolvers() {
final ContextTypeRegistry codeTemplateContextRegistry = JavaPlugin.getDefault().getCodeTemplateContextRegistry();
final Iterator ctIter = codeTemplateContextRegistry.contextTypes();
while (ctIter.hasNext()) {
final TemplateContextType contextType = (TemplateContextType) ctIter.next();
contextType.addResolver(new BundleIdResolver());
contextType.addResolver(new BundleVersionResolver());
}
}

Andreas Höhmann has found another http://ahoehma.wordpress.com/2009/08/24/use-maven-artifact-v ersion-in-eclipse-templates/ for the similar problem.

I hope this helps ;)
Have a nice day.
Re: Adding Global Variable [message #604799 is a reply to message #446267] Thu, 25 February 2010 07:36 Go to previous message
jefier is currently offline jefierFriend
Messages: 2
Registered: February 2010
Junior Member
Thanks for sharing such a nice sharing.it is very useful for all keep it up.i will come back to see more update.

--
Get information about http://www.actualtests.com/vendors-training/Oracle.htm online now.


Get information about oracle certification online now.
Previous Topic:How do I enable tracing during pde headless build
Next Topic:PDE Headless build
Goto Forum:
  


Current Time: Sun Nov 23 18:54:15 GMT 2014

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

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