org.openide.loaders 7.37

org.netbeans.api.templates
Annotation Type TemplateRegistration


@Target(value={TYPE,METHOD,PACKAGE})
@Retention(value=SOURCE)
public @interface TemplateRegistration

Registers a template the user can select. May be placed on a class (with a default constructor) or static method (with no arguments) to register an WizardDescriptor.InstantiatingIterator for a custom template; or on a package to register a plain-file template with no custom behavior.

Since:
7.29
See Also:
TemplateWizard, TemplateRegistrations, org.netbeans.spi.project.ui.templates.support

Required Element Summary
 String folder
          Subfolder in which to place the template, such as Other or Project/Standard.
 
Optional Element Summary
 String[] category
          Optional list of categories interpreted by the project system.
 String[] content
          File contents, as resources relative to the package of this declaration.
 String description
          Optional but recommended relative resource path to an HTML description of the template.
 String displayName
          Localized label for the template.
 String iconBase
          Icon to use for the template.
 String id
          Special file basename to use rather than inferring one from the declaring element, when content() is empty.
 int position
          Optional position within folder().
 String scriptEngine
          Optional name of a script engine to use when processing file content, such as freemarker.
 

Element Detail

folder

public abstract String folder
Subfolder in which to place the template, such as Other or Project/Standard.

position

public abstract int position
Optional position within folder().

Default:
2147483647

id

public abstract String id
Special file basename to use rather than inferring one from the declaring element, when content() is empty. Useful for pure templates referenced from PrivilegedTemplates.

Default:
""

content

public abstract String[] content
File contents, as resources relative to the package of this declaration. A nonempty list is mandatory for a template registered on a package. For a template with a custom iterator, the content may be omitted, though it may still be specified.

Normally only a single file is specified, but for a multifile data object, list the primary entry first.

The file basenames (incl. extension) of the actual template files (as in TemplateWizard.getTemplate()) will be taken from the basename of the content resources, though a .template suffix may be appended to prevent template resources in a source project from being misinterpreted. For a "pure" custom iterator with no specified content, the template basename defaults to the FQN of the class or method defining it but with - for . characters, e.g. pkg-Class-method, but may be overridden with id().

Example usage for a simple, single-file template (with or without custom iterator):

content="resources/empty.php"

For a form template:

content={"Login.java.template", "Login.form.template"}

Default:
{}

displayName

public abstract String displayName
Localized label for the template. Mandatory unless content() is specified, in which case it would be defaulted by the data node. May use the usual #key syntax.

Default:
""

iconBase

public abstract String iconBase
Icon to use for the template. Should be an absolute resource path (no initial slash). Mandatory unless content() is specified, in which case it would be defaulted by the data node.

Default:
""

description

public abstract String description
Optional but recommended relative resource path to an HTML description of the template.

See Also:
TemplateWizard.getDescription(org.openide.loaders.DataObject)
Default:
""

scriptEngine

public abstract String scriptEngine
Optional name of a script engine to use when processing file content, such as freemarker.

See Also:
ScriptEngineFactory.getNames()
Default:
""

category

public abstract String[] category
Optional list of categories interpreted by the project system.

Default:
{}

org.openide.loaders 7.37

Built on May 25 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.