blob: 7e4140d2ad00e68778f91b87b820483261bea16b [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= DevFaqMakeGroupTemplate
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqMakeGroupTemplate
:description: Apache NetBeans wiki DevFaqMakeGroupTemplate
:toc: left
:toc-title:
:syntax: true
=== How do I make a file template which actually creates more than one file?
For example, say you want to make a template which will appear in *File | New File* which will prompt the user for a name and location but then actually create several related files.
Just use an arbitrary empty file as the template, and declare it to have an `instantiatingWizardURL` attribute with an instance of `WizardDescriptor.InstantiatingIterator`. The wizard iterator can specify any sequence of Swing panels you like to ask the user whatever questions you like, and at the end it can do whatever you like to create the new files. Return the created files in `instantiate()`.
Here is an link:http://hg.netbeans.org/main/file/tip/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/librarydescriptor/[example of a wizard that creates a number of files]. This is the link:http://hg.netbeans.org/main/file/tip/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/resources/layer.xml[layer file that declares it] (look at `emptyLibraryDescriptor`).
You may wish to reuse a standard GUI panel for picking a folder and name, as in
`link:http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-projectuiapi/org/netbeans/spi/project/ui/templates/support/Templates.html#createSimpleTargetChooser(org.netbeans.api.project.Project,%20org.netbeans.api.project.SourceGroup[Templates.createSimpleTargetChooser]`.
The NetBeans 5.0 module development support has a (meta-)wizard *New Wizard*. Choose *New File* for *Registration Type* and follow the wizard steps.
See also link:https://blogs.oracle.com/geertjan/entry/multiple_files_from_a_single[https://blogs.oracle.com/geertjan/entry/multiple_files_from_a_single] (and its comments)
---
Applies to: NetBeans 5.0, 5.5, 6.X
=== Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/DevFaqMakeGroupTemplate[http://wiki.netbeans.org/DevFaqMakeGroupTemplate] ,
that was last modified by NetBeans user Markiewb
on 2013-07-28T14:06:22Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.