Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Help with template creation
Help with template creation [message #901342] Fri, 10 August 2012 23:35 Go to next message
Ray Holguin is currently offline Ray HolguinFriend
Messages: 3
Registered: August 2012
Junior Member
So if I declare a private member such as

private MyObject test;

I want to create a template that will generate code in the following format

public MyObject retrieveAllMyObjects() {
    return test.findAll();
}

I have been messing around with the templates but I can't even figure out how to activate the templates. when I do the Ctrl+Space i just get no template proposals message

public ${return_type} retrieveAll${field}s() {

}


Obviously this is just a starting point, i was just trying to see if i could get eclipse to generate this and then I would go from there, but no such luck. My template doesn't show up anywhere. The context im using is "Java Type Members" what am I doing wrong??
Re: Help with template creation [message #901409 is a reply to message #901342] Sat, 11 August 2012 22:37 Go to previous messageGo to next message
Vlad Gheorghe is currently offline Vlad GheorgheFriend
Messages: 127
Registered: May 2011
Senior Member

Hi,

Reading through the variables specification, I think this one is more close :

public ${t:elemType(x)} retrieveAll${x:field}s() {

}


Also, the categories that content assist provides are configured in Java > Editor > Content Assist > Advanced.


However, I could not get this working either (new the template is not listed in the proposal list)

Cheers,
Vlad

[Updated on: Sun, 12 August 2012 08:47]

Report message to a moderator

Re: Help with template creation [message #901549 is a reply to message #901342] Mon, 13 August 2012 10:42 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 11.08.2012 01:35, Ray Holguin wrote:
> So if I declare a private member such as
>
>
> private MyObject test;
>
> I want to create a template that will generate code in the following
> format
>
> public MyObject retrieveAllMyObjects() {
> return test.findAll();
> }
> I have been messing around with the templates but I can't even figure
> out how to activate the templates. when I do the Ctrl+Space i just get
> no template proposals message
You need to type at least one character to get templates proposals.

Dani
>
> public ${return_type} retrieveAll${field}s() {
>
> }
>
> Obviously this is just a starting point, i was just trying to see if i
> could get eclipse to generate this and then I would go from there, but
> no such luck. My template doesn't show up anywhere. The context im
> using is "Java Type Members" what am I doing wrong??
Re: Help with template creation [message #901606 is a reply to message #901342] Mon, 13 August 2012 16:11 Go to previous messageGo to next message
Ray Holguin is currently offline Ray HolguinFriend
Messages: 3
Registered: August 2012
Junior Member
Ok so i was able to get my code template to work only if i edited one of the existing templates in the system to use my code. I took the "private_static_method" stock template and put my code in and it worked. but if I create a new template with the same exact configuration it does not appear. does anyone know if you have to do something special to get new templates to register in eclipse so they can be used?
Re: Help with template creation [message #901610 is a reply to message #901606] Mon, 13 August 2012 16:20 Go to previous messageGo to next message
Ray Holguin is currently offline Ray HolguinFriend
Messages: 3
Registered: August 2012
Junior Member
nevermind I got it working, thanks guys for the help.
Re: Help with template creation [message #901971 is a reply to message #901610] Wed, 15 August 2012 11:17 Go to previous message
Vlad Gheorghe is currently offline Vlad GheorgheFriend
Messages: 127
Registered: May 2011
Senior Member
Can you post your results for reference ?

Thanks
Vlad
Previous Topic:Change Event for IContentDescriber
Next Topic:Relationship between code and architecture
Goto Forum:
  


Current Time: Thu Apr 25 23:58:03 GMT 2024

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

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

Back to the top