Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 11020 - [templates] Template support beyond Java editor
Summary: [templates] Template support beyond Java editor
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Tom Hofmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 33639 (view as bug list)
Depends on:
Blocks: 49383
  Show dependency tree
 
Reported: 2002-03-08 08:59 EST by Xavier Méhaut CLA
Modified: 2004-08-06 17:47 EDT (History)
6 users (show)

See Also:


Attachments
example of using templates in TextEditor (9.22 KB, text/plain)
2004-02-27 12:30 EST, Tom Hofmann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xavier Méhaut CLA 2002-03-08 08:59:22 EST
Hello,
I saw that Eclipse had implemenented a template feature, and it is very 
useful ... Nevertheless, it runs only for java source code, and not for other 
file types... For instance, we want to edit a JSP file and we want to add some 
template for this type of file... It seems that we couldn't use the template 
written by using a CTRL-Space... Is it true?  Actually, it could be useful to 
be able to describe templates like a Clip library in Textpad, clip dedicated to 
a particular type of file...
Best regards
Xavier
Comment 1 Erich Gamma CLA 2002-03-11 08:36:07 EST
for 2.0 templates are constrained to the Java editor only.
we will consider generalizing templates after 2.0
Comment 2 Dirk Baeumer CLA 2002-07-23 09:33:02 EDT
Reopening for 2.1 consideration
Comment 3 Kai-Uwe Maetzel CLA 2003-01-13 12:16:06 EST
"Unassign" PRs because of changes in staffing
Comment 4 Tom Hofmann CLA 2004-02-17 04:28:28 EST
*** Bug 33639 has been marked as a duplicate of this bug. ***
Comment 5 Tom Hofmann CLA 2004-02-27 12:27:25 EST
Progress so far:

- LinkedPosition infrastructure has been moved down
    - package org.eclipse.jface.text.link
     (check both org.eclipse.jface.text and org.eclipse.text)
    - org.eclipse.ui.texteditor.link

Everything is still moving, but I don't expect too many changes to the API here.
There were some screen updating problems when I tested it with the text editor
which will need fixing (probably by making use of some generic painting
infrastructure, not using AnnotationPainter any longer).

- A first cut of Templates has been moved down
    - package org.eclipse.jface.text.templates in org.eclipse.text
    - package org.eclipse.jface.text.templates in org.eclipse.jface.text
    - package org.eclipse.ui.workbench.texteditor.templates

This transition is still very much incomplete. There is no contribution story,
no preference page etc etc. I will attach a very crude patch to TextEditor that
shows how the template stuff can be used.

Feel free to play around, please attach comments to this bug report.
Comment 6 Tom Hofmann CLA 2004-02-27 12:30:38 EST
Created attachment 8218 [details]
example of using templates in TextEditor

Adds a new action bound to Ctrl+5 to the texteditor which will insert a
template. Screen updating is still buggy.
Comment 7 Kai-Uwe Maetzel CLA 2004-03-26 11:34:46 EST
Changing milestone to M9.
Comment 8 Kai-Uwe Maetzel CLA 2004-03-26 11:36:27 EST
.
Comment 9 Tom Hofmann CLA 2004-03-31 04:40:05 EST
fixed > 20040330 

(everything is in M8 already, besides the Java editor using the new infrastructure).

--

Added the org.eclipse.ui.editors.templates extension point.

You can:
- add templates to existing context types (e.g. "java" and "javadoc" context
types in the java editor)
- define your own context types for your custom editor
- define variable resolvers for an existing context type

As an editor implementor, you have the choice of whether you want to allow
contributed variable resolvers for the context types you define. The java editor
does not pick them up currently.

--

See the example template editor in the org.eclipse.ui.examples.javaeditor
plug-in for an example of how you can add templates to your custom editor.

You also get:
- A store for contributed and (possibly) user-added templates
- An almost complete skeleton of a templates preference page
- content assist proposals for templates