Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / February 2004

Tip: Looking for answers? Try searching our database.

Eclipse: Template Variable Creation

Thread view: 
P.Hill - 02 Feb 2004 16:41 GMT
'Twas blind but...
Where in Eclipse do I do I add a Template Variable?

I was thinking of adding a few template variables, aka those
things that have ${...} that result in dynamic substitution when
Java code is generated.   I was thinking of starting out with baby steps
and something fixed like ${author} or maybe ${copyright} so that
I can use them in code generation.

Window | Java | Code Generation

Several places in the docs discuss:

"You can insert your own template variables, which then evaluate to the name of
the variable itself. You must, however, make sure that the name does not
conflict with the pre-defined template variable names in the specific context."
  -- Java Development Users Guide On-line Help: Writing your own templates
http://127.0.0.1:1574/help/index.jsp?tab=links&contextId=org.eclipse.jdt.ui.edit
_template_dialog_context&topic=%2Forg.eclipse.jdt.doc.user%2Fconcepts%2Fctemplat
es.htm


I thought

Window | Java | Editor | Templates
might eventually lead me to something, but New | insert variable just gives me
the current list.

Where is it?
Is this a PDE Function?

-Paul
A.Buschmann - 21 Feb 2004 17:23 GMT
Hello Paul,

<snip>
>those things that have ${...} that result in dynamic substitution when
>Java code is generated
<snip>
I don't think that this could be possible, because some of the predefined
Variables have some
action behind them, like searching for an array, so I think they are defined
somewhere in the Source Code.

> "You can insert your own template variables, which then evaluate to the name of
> the variable itself.
<snip>

I think you didn't get that right.
They wrote: "evaluate to the name of the variable itself" and that's exactly
what is meant.
1. Try defining a template in "preferences->java->editor->templates" with
name "TempTest"
2. write somewhere in this Template: ${MyTestVariable}
3. open a Java-Editor
4. Type in: "TempTest" and press Ctrl-Space.
In the Source-Code now ${MyTestVariable} is replaces with "MyTestVariable".
That's neither nice nor smothe, but it's exactly
what the help is saying.

Now you are asking: Why then define an Template Variable?
Because when the same Variable appears more than once and you overwrite the
Variable right after pressing Ctrl-Space,
all occurences are replaced at the same time.

For more infos, look into the Eclipse-Help:
Getting Started->Basic tutorial->Editing Java Elements->Using source code
templates

Alex


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.