Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] Template support

From: "Nick Edgar" <Nick_Edgar@xxxxxxxxxx>
> I'd also like to encourage others in the community to list their
> requirements too, and get involved in other ways if interested.

Here's a use case: A feature several of my plugin users have requested is
the ability to use one of their own documents as a template when creating
new documents. They want to be able to set up such documents as defaults on
a per-extension basis and to be able to specify one in the New dialog.

I have an experimental implementation of this in the next version of my
editor. While implementing it, several requirements suggested themselves:

- First, a terminology problem. We must distinguish between file templates
and what JDT currently calls templates. I will call the latter macro
templates.

- Users will not want to rewrite their exemplar documents in order for them
to serve as templates. Zero learning should be required. This implies that
file templates should not be (required to be) in the form of XML documents
or other unnatural formats, but that the default file template expansion is
a simple copy.

- Users will not want these exemplar documents required to be located in a
single project or workspace. I deal with that by allowing relative (with
full ../.. support) and absolute paths and even URLs (but of course I have a
caching mechanism that takes the pain out of routine use of internet
resources).

- Conversely, some users will want to take advantage of standard macro
templates used by the wizard, like the JDT filecomment. It may also be true
that the project or file creation wizard will define values of additional
macro templates that may be expanded in the course of expanding the file
template(s). My wizards do this using my internal macro templates. This
implies that a) there must be a textual way of requesting the expansion of a
macro template, e.g., ${filecomment} and b) the standard/wizard macro
templates must be documented and become API.

- This consideration strongly suggests that the macro template mechanism be
factored out of JDT and into a generic package that is applicable to all
editors and can be used for file template expansion. I wrote my own for code
assist and later for wizard expansion. I think that's enough use case right
there.

- A minor point, but if users are to be able to define their own macro
templates and if these templates are to be used as ${filecomment} above,
this implies that macro expansions are re-scanned (which is standard enough
in the macro world, but may be a novelty to JDT templates).

- "Expansion" for file or project wizards requires a) the ability to create
directories, if they do not already exist, b) the ability to copy zero or
more existing files or resources (in the Java sense) into each such
directory, c) with optional macro template expansion within each file.

- And, of course, the requirement that started it all, that users, not just
plug-in developers, be able to supply file templates used by standard and
plug-in supplied wizards.

Bob



Back to the top