org.openide.loaders
Class CreateFromTemplateHandler
java.lang.Object
org.openide.loaders.CreateFromTemplateHandler
public abstract class CreateFromTemplateHandler
- extends Object
This is an interface for smart templating
that allows
any module to intercept calls to DataObject.createFromTemplate(org.openide.loaders.DataFolder)
and handle them themselves. The NetBeans IDE provides default
implementation that allows use of Freemarker templating engine.
Read more in the howto document.
- Since:
- 6.1
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FREE_FILE_EXTENSION
public static final String FREE_FILE_EXTENSION
- Parameter to enable free file extension mode.
By default, the extension of the newly created file will be inherited
from the template. But if
createFromTemplate(org.openide.filesystems.FileObject, org.openide.filesystems.FileObject, java.lang.String, java.util.Map)
is called with this
parameter set to Boolean.TRUE
(such as from DataObject.createFromTemplate(DataFolder,String,Map)
),
and the file name already seems to
include an extension (*.*), the handler should not append
any extension from the template.
- Since:
- org.openide.loaders 7.16
- See Also:
Templates.SimpleTargetChooserBuilder.freeFileExtension
,
Constant Field Values
CreateFromTemplateHandler
public CreateFromTemplateHandler()
accept
protected abstract boolean accept(FileObject orig)
- Method that allows a handler to reject a file. If all handlers
reject a file, regular processing defined in
DataObject.handleCreateFromTemplate(org.openide.loaders.DataFolder, java.lang.String)
is going to take place.
- Parameters:
orig
- the file of the template
- Returns:
- true if this handler wants to handle the createFromTemplate operation
createFromTemplate
protected abstract FileObject createFromTemplate(FileObject orig,
FileObject f,
String name,
Map<String,Object> parameters)
throws IOException
- Handles the creation of new file.
- Parameters:
orig
- the source filef
- the folder to create a file inname
- the name of new file to create in the folder (see FREE_FILE_EXTENSION
regarding extension)parameters
- map of additional arguments as specified by registered CreateFromTemplateAttributesProvider
s
- Returns:
- the newly create file
- Throws:
IOException
- if something goes wrong with I/O