MyEclipse: Can't get java template to work in myeclipse or eclipse Mac

Zscipio - Apr 06, 2012 - 08:50 PM
Post subject: Can't get java template to work in myeclipse or eclipse Mac
I can't get java templates to work. For example if an "if" statement is wanted I looked in Preferences-->Java-->Editor-->Templates--if and the check box is checked next to "if" and the Preview says
Code:
if (${condition:var(boolean)}) {
   ${line_selection}${cursor}
}

I then edit a class and try to use the template.
I have tried typing 'if' then pressing command+space and nothing happens.
I have tried selecting the 'if' then pressing command+space and nothing happens.
If I type 'if' then select it and press control+space the choice of 'runnable' is available and when chosen inserts the code
Code:
new Runnable() {
   public void run() {
      if
   }

Any suggestions?
support-tony - Apr 09, 2012 - 10:55 AM
Post subject:
Zscipio,

This functionality is base eclipse functionality, so you may get better support by posting in an eclipse user forum. However, I couldn't replicate the problem with either eclipse or MyEclipse on Mac OS X Lion.

Note that the content assist key combination is Ctrl-Space, which is not one of the combinations you mentioned. Command-Space opens the Mac Spotlight search box. If you select some text and then hit Ctrl-Space, the content assist operates in a different mode, though it's hard to understand why it would offer Runnable, in your case. If you select a full if statement (or any other statement or block of statements) then a Runnable choice seems reasonable.

Note that Ctrl-Space actually cycles through various sets of proposals. Note the message at the bottom of the pop-up which shows which set of proposals will come up next if you hit Ctrl-Space again.

The key combinations can be changed in the preferences, so you might want to check that.
Zscipio - Apr 11, 2012 - 09:51 PM
Post subject: Meaning of "Context" in Preferences-->Templates
You reply gave me enough hints so that the Content Assist now works. But I don't understand why the process works. I went into the templates and changed the "Context" value of the "if" template from "Java statements" to "Java". What do the values in the "Context" column mean? The values in this column are:
1. Java
2. Java statements
3. SWT statements
4. Javadoc
5. Java type members
I have done a Google search on the meanings of the entries in the "Context" column but to no avail.

Thank you for your help.
support-swapna - Apr 12, 2012 - 11:54 AM
Post subject:
Zscipio,

Glad that it is working.

For more details on the context values, please take a look at these links:
http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fpreferences%2Fjava%2Feditor%2Fref-preferences-edit-template-dialog.htm
http://fahdshariff.blogspot.in/2011/08/useful-eclipse-templates-for-faster.html

Hope this helps.
All times are GMT - 6 Hours
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits