org.openide.loaders 7.21.1

org.openide.loaders
Class CreateFromTemplateHandler

java.lang.Object
  extended by 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

Field Summary
static String FREE_FILE_EXTENSION
          Parameter to enable free file extension mode.
 
Constructor Summary
CreateFromTemplateHandler()
           
 
Method Summary
protected abstract  boolean accept(FileObject orig)
          Method that allows a handler to reject a file.
protected abstract  FileObject createFromTemplate(FileObject orig, FileObject f, String name, Map<String,Object> parameters)
          Handles the creation of new file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

CreateFromTemplateHandler

public CreateFromTemplateHandler()
Method Detail

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 file
f - the folder to create a file in
name - 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 CreateFromTemplateAttributesProviders
Returns:
the newly create file
Throws:
IOException - if something goes wrong with I/O

org.openide.loaders 7.21.1

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.