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 19:35 Go to next message
Ray Holguin is currently offline Ray Holguin
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 18:37 Go to previous messageGo to next message
Vlad Gheorghe is currently offline Vlad Gheorghe
Messages: 111
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 04:47]

Report message to a moderator

Re: Help with template creation [message #901549 is a reply to message #901342] Mon, 13 August 2012 06:42 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
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 12:11 Go to previous messageGo to next message
Ray Holguin is currently offline Ray Holguin
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 12:20 Go to previous messageGo to next message
Ray Holguin is currently offline Ray Holguin
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 07:17 Go to previous message
Vlad Gheorghe is currently offline Vlad Gheorghe
Messages: 111
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 Aug 21 14:02:47 EDT 2014

Powered by FUDForum. Page generated in 0.02185 seconds