Open Issues in handling file templates in NetBeans IDE

NetBeans IDE uses a bunch of static file templates which are predefined in corresponing NetBeans project types. IDE users want to add or modify own set of file templates and extend predefined templates with own one. This document summaries known problems which users found out and also missing features which should make templates handling more consistent in IDE.

Note that current kind of templates handling was introduced in prehistoric NetBeans releases and don't reflect using template engines like FreeMarker yet. Also current Template Manager was introduced before using template engines.

Tracked as issue Issue 153941


Known problems

Attaching attributes e.g. Template Engine


  • Issue 140256
  • Several important properties of template are holding in FileObject attributes of predefined file templates. Templates created/saved as template by IDE users don't have such attributes.
  • Attribute can hold Template Engine, localizing bundle and more
  • Need to allow users to edit these attributes, e.g. allow attach some of available Template Engines while creating new template


Inability to set/edit Display Name


The cause of this that Template Manager is built on FileObjects w/o display name, which are wrapped in DataObjects which read from localizing bundle. Unluckily inplace editing invoked from TemplateManager edits file name instead of DO display name. Need to reconsider using pattern for gaining nodes:

        DataFolder df = DataFolder.findFolder (getTemplatesRoot ());
        return new TemplateNode (new FilterNode (df.getNodeDelegate (), df.createNodeChildren (new TemplateFilter ())));
  • Use the attribute displayName instead of SystemFileSystem.localizingBundle on custom templates


Inability to set/edit Description

Dtto above + need to enlarge TemplateManager for editing Descriptions.

  • The bigger problem is where to place custom edited descriptions.
  • Use object serialization?
  • Use absolute paths to custom html file placed in userdir?

Inability to attach own Icon

Dttd above

Troubles with sorting template's categories


The next problem caused using DataFolder, set order on DataFolder makes it permanent and affects order shown in New File wizard. It's difficult to keep template's categories sorted in TemplateManager and given order in New File wizard. }}

Missing features

Import templates between IDE instances

  • A usual use-case for file templates, somewhere in team's storage are bunch of team's specific templates (e.g. action pattern, particular forms etc.) New member of the team should have a chance to import all these team's templates and work with them. In this sense Template Manager should support export set of templates to any portable format and import such format vice versa.
  • Should to have feature

Code completion of predefined variables for FreeMarker

  • To have a template specific editor which understands FreeMarker syntax and simplifying editing file templates.
  • Nice to have in the future
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo