blob: e99c0126f2f9552ed05f06680b3a0c447df5185d [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.
-->
===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 <tt>instantiatingWizardURL</tt> attribute with an instance of <tt>WizardDescriptor.InstantiatingIterator</tt>. 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 <tt>instantiate()</tt>.
Here is an [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 [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 <tt>emptyLibraryDescriptor</tt>).
You may wish to reuse a standard GUI panel for picking a folder and name, as in
<tt>[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]</tt>.
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 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 http://wiki.netbeans.org/DevFaqMakeGroupTemplate ,
that was last modified by NetBeans user Markiewb
on 2013-07-28T14:06:22Z.