|
|||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
Templates | Default implementations of template UI. |
Support for providing own templates visible in New File... action.
Project types may declare the templates for projects in the folder Templates/Projects
on the
system filesystem using a module XML layer file. Registering project type templates is similar to registering
file templates described below. The wizard for a project can return DataObject
s or
FileObject
s corresponding to the project directories of created files and/or files
to be selected in newly created projects. The WizardDescriptor
may also have a property
defined on it called setAsMain
, which may be Boolean#TRUE
(the default) or Boolean#FALSE
, according to whether the (first returned) new project should be set as the main project or
not.
Each project can also declare own file templates to be exposed it in New File... wizard. This permits users to create new files, which are of types supported by given project type. The project may also provide own iterator for project-specific customization of given file type.
The project type has to declare its file templates in the module's layer file
in folder the Templates
. The declaration should look as follows:
<folder name="Templates">
<folder name="JSP_Servlet">
<file name="JSP.jsp" url="templates/JSP.template">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.web.core.Bundle"/>
<attr name="template" boolvalue="true"/>
<attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/web/core/resources/JSP.html"/>
<attr name="instantiatingIterator" methodvalue="org.netbeans.modules.web.dd.wizards.PageIterator.createJspIterator"/>
<attr name="templateCategory" stringvalue="web-types"/>
</file>
</folder>
</folder>
Templates
folder specify the folder in which will
be this templates present in templates chooser invoked from either New File...
or New Project... wizard.file
tag has to have a unique name
to
recognize in the SystemFileSystem
and the url
property which links to file pattern of the declared template.
The mandatory file's attributes are:
SystemFileSystem.localizingBundle
specifies the ResourceBundle
which contains the localized display name of templatetemplate
which must have value set to true
otherwise the template will be ignored.instantiatingWizardURL
links to a resource with a template's descriptioninstantiatingIterator
specifies a instance of WizardDescriptor.InstantiatingIterator
which instantiates the new file in specified target folder.Note: a project type can declare own custom iterator with some project-specific customization, it's recommended to use the standardized target chooser exposed inTemplates.createSimpleTargetChooser(...)
, a similar target chooser offersJavaTemplates.createPackageChooser(...)
for Java-oriented projects. The project type also can use aInstantiatingIterator
published by other module, i.e.JavaTemplates.createJavaTemplateIterator()
useful for Java-oriented templates in case of no needs to own customization. The last possibility is declaration no iterator, in this case will be used a generic iterator useful for simple file types without any specific needs, i.e.properties file
.
For project templates theinstantiate()
method should return a Set of FileObjects. FileObjects representing project directories will automatically be opened in the project and files tab. Other FileObjects (e.g. Java classes created by the wizard) will be opened in the editor area. Path of coresponding nodes will be expanded in the project or files tab.
For file templates theinstantiate()
method should return Set of FileObjects which will then automaticaly opened in the editor. Path of coresponding nodes will be expanded in the project or files tab.
templateCategory
files the template to some category. The template's categories
helps to filter the templates according to type of project.
You may specify multiple categories separated by commas, e.g.: some-type,some-other-typeThere are two importatnt interfaces affecting the behavior of the templates. Implementation of these interfaces should reside in the project's lookup.
The first one is PrivilegedTemplates
.
It is used for the initial content of the popup menu of New File.... It simply should return names of file tempolates from system
filesystem which should be contained in the popup menu. Example implementation follows:
private static final class PrivilegedTemplatesImpl implements PrivilegedTemplates {
private static final String[] PRIVILEGED_NAMES = new String[] {
"Templates/Classes/Class.java",
"Templates/Classes/Package",
"Templates/Classes/Interface.java",
"Templates/GUIForms/JPanel.java",
"Templates/GUIForms/JFrame.java",
};
public String[] getPrivilegedTemplates() {
return PRIVILEGED_NAMES;
}
}
The second interface is RecommendedTemplates
,
which infulences the apperance of templates in the New File wizard according to project types. The implementation of the interface has to return
array of Strings which corresponds to names of template categories listed in the templateCategory
attribute of template files. All templates
which list at least one recommended category in the templateCategory
attribute will be listed for given project type.
Note: if no templateCategory
is declared then this template will be visible for each project regardless its type.
Example implementation of RecommendedTemplates
interface:
private static final class RecommendedTemplatesImpl implements RecommendedTemplates {
// List of primarily supported templates categories
private static final String[] TYPES = new String[] {
"java-classes",
"java-main-class",
"java-forms",
"gui-java-application",
"java-beans",
"oasis-XML-catalogs",
"XML",
"ant-script",
"ant-task",
"junit",
"simple-files"
};
public String[] getRecommendedTypes() {
return TYPES;
}
}
templateCategory | |
java-classes | |
java-classes-basic | same as java-classes excluding Applet/JApplet |
java-main-class | (all together could be pooled as generic-java) |
java-beans | |
java-forms | |
gui-java-application | (all above could be pooled as java) |
web-types | |
servlet-types | |
XML | |
oasis-XML-catalogs | |
ant-script | |
ant-task | |
junit | |
simple-files | |
MIDP |
Projects:
* - supported file type
File Type \ Project | JA | JL | JP | WA | WP |
---|---|---|---|---|---|
Folder | * | * | * | * | * |
Java Package | * | * | * | * | * |
Java Class | * | * | * | * | * |
Empty Java File | * | * | * | * | * |
Java Interface | * | * | * | * | * |
Java Exception | * | * | * | * | * |
Java Main Class | * | * | * | ||
JApplet Form | * | * | * | ||
JDialog Form | * | * | * | ||
JFrame Form | * | * | * | ||
JInternalFrame Form | * | * | * | ||
JPanel Form | * | * | * | ||
Bean Form | * | * | * | ||
Applet Form | * | * | * | ||
Dialog Form | * | * | * | ||
Frame Form | * | * | * | ||
Panel Form | * | * | * | ||
Application | * | * | |||
MDI Application | * | * | |||
OK/Cancel Dialog | * | * | * | ||
Java Bean | * | * | * | * | * |
BeanInfo | * | * | * | * | * |
BeanInfo w/o Icon | * | * | * | * | * |
Customizer | * | * | * | * | * |
Property Editor | * | * | * | * | * |
Simple JUnit TestCase | * | * | * | ||
File Type \ Project | JA | JL | JP | WA | WP |
XML Document | * | * | * | * | * |
DTD Entity | * | * | * | * | * |
XML Schema | * | * | * | * | * |
XSL Stylesheet | * | * | * | * | * |
OASIS XML Catalog | * | * | * | * | * |
XML Parsed Entity | * | * | * | * | * |
Cascading Style Sheet | * | * | * | * | * |
Empty Ant Script | * | * | * | * | * |
Custom Task | * | * | * | * | * |
HTML File | * | * | * | * | * |
Properties File | * | * | * | * | * |
Text File | * | * | * | * | * |
JSP | * | * | |||
Servlet | * | * | * | * | |
HTML | * | * | |||
Web Module Listener | * | * | |||
Filter | * | * | |||
Tag File | * | * | * | * | |
Tag Handler | * | * | * | * | |
Tag Library Descriptor | * | * | * | * |
|
|||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |