public class Templates extends Object
For methods which take a WizardDescriptor
parameter,
use the wizard as passed to WizardDescriptor.InstantiatingIterator.initialize(org.openide.WizardDescriptor)
or TemplateWizard.Iterator.initialize(org.openide.loaders.TemplateWizard)
.
Modifier and Type | Class and Description |
---|---|
static class |
Templates.SimpleTargetChooserBuilder
A builder for simple target choosers.
|
Modifier and Type | Method and Description |
---|---|
static Templates.SimpleTargetChooserBuilder |
buildSimpleTargetChooser(Project project,
SourceGroup[] folders)
Builder for simple target choosers.
|
static WizardDescriptor.Panel<WizardDescriptor> |
createSimpleTargetChooser(Project project,
SourceGroup[] folders)
|
static WizardDescriptor.Panel<WizardDescriptor> |
createSimpleTargetChooser(Project project,
SourceGroup[] folders,
WizardDescriptor.Panel<WizardDescriptor> bottomPanel)
|
static boolean |
getDefinesMainProject(WizardDescriptor wizardDescriptor)
Checks whether a project wizard will set the main project.
|
static FileObject |
getExistingSourcesFolder(WizardDescriptor wizardDescriptor)
Find the existing sources folder selected for a custom template wizard iterator.
|
static Project |
getProject(WizardDescriptor wizardDescriptor)
Find the project selected for a custom template wizard iterator.
|
static FileObject |
getTargetFolder(WizardDescriptor wizardDescriptor)
Find the target folder selected for a custom template wizard iterator.
|
static String |
getTargetName(WizardDescriptor wizardDescriptor)
Method to communicate current choice of target name to a custom
WizardDescriptor.InstantiatingIterator associated with particular template. |
static FileObject |
getTemplate(WizardDescriptor wizardDescriptor)
Find the template with which a custom template wizard iterator is associated.
|
static void |
setDefinesMainProject(WizardDescriptor wizardDescriptor,
boolean definesMainProject)
Deprecated.
Projects should not be set as main by default.
|
static void |
setTargetFolder(WizardDescriptor wizardDescriptor,
FileObject folder)
Stores a target folder so that it can be remembered later using
Templates.getTargetFolder(org.openide.WizardDescriptor) . |
static void |
setTargetName(WizardDescriptor wizardDescriptor,
String targetName)
Sets the target name for given WizardDescriptor to be used from
custom target choosers
|
public static Project getProject(WizardDescriptor wizardDescriptor)
If the user selects File | New File, this will be the project chosen in the first panel.
If the user selects New from CommonProjectActions.newFileAction()
, this will
be the project on which the context menu was invoked.
wizardDescriptor
- a file wizard, not null.public static FileObject getTemplate(WizardDescriptor wizardDescriptor)
If the user selects File | New File, this will be the template chosen in the first panel.
If the user selects New from CommonProjectActions.newFileAction()
, this will
be the template selected from the context submenu.
wizardDescriptor
- a file or project wizardpublic static FileObject getTargetFolder(WizardDescriptor wizardDescriptor)
If the user selects File | New File
this may not be set, unless you have called Templates.setTargetFolder(org.openide.WizardDescriptor, org.openide.filesystems.FileObject)
in an earlier panel (such as that created by Templates.createSimpleTargetChooser(Project,SourceGroup[])
).
It may however have a preselected folder, e.g. if the user invoked New from
the context menu of a folder.
wizardDescriptor
- a file wizardpublic static FileObject getExistingSourcesFolder(WizardDescriptor wizardDescriptor)
This may not be set, unless you have CommonProjectActions.newProjectAction()
with CommonProjectActions.EXISTING_SOURCES_FOLDER
value.
wizardDescriptor
- a project wizardpublic static void setTargetFolder(WizardDescriptor wizardDescriptor, FileObject folder)
Templates.getTargetFolder(org.openide.WizardDescriptor)
.wizardDescriptor
- a file wizardfolder
- a target folder to rememberpublic static String getTargetName(WizardDescriptor wizardDescriptor)
WizardDescriptor.InstantiatingIterator
associated with particular template.wizardDescriptor
- a file wizardTemplateWizard.getTargetName()
,
ProjectChooserFactory.WIZARD_KEY_TARGET_NAME
public static void setTargetName(WizardDescriptor wizardDescriptor, String targetName)
wizardDescriptor
- a file wizardtargetName
- a desired target nameTemplateWizard.setTargetName(java.lang.String)
,
ProjectChooserFactory.WIZARD_KEY_TARGET_NAME
public static boolean getDefinesMainProject(WizardDescriptor wizardDescriptor)
wizardDescriptor
- a project wizard@Deprecated public static void setDefinesMainProject(WizardDescriptor wizardDescriptor, boolean definesMainProject)
wizardDescriptor
- a project wizarddefinesMainProject
- true if it will set a main project@Deprecated public static WizardDescriptor.Panel<WizardDescriptor> createSimpleTargetChooser(Project project, SourceGroup[] folders)
@Deprecated public static WizardDescriptor.Panel<WizardDescriptor> createSimpleTargetChooser(Project project, SourceGroup[] folders, WizardDescriptor.Panel<WizardDescriptor> bottomPanel)
public static Templates.SimpleTargetChooserBuilder buildSimpleTargetChooser(@NullAllowed Project project, @NonNull SourceGroup[] folders)
DataObject.createFromTemplate(org.openide.loaders.DataFolder)
.project
- The project to work on.folders
- a nonempty list of possible roots to create the new file in,
or an empty list if project
is null