public class TemplateWizard extends WizardDescriptor
TemplateRegistration
Modifier and Type | Class and Description |
---|---|
static interface |
TemplateWizard.Iterator
The interface for custom iterator.
|
WizardDescriptor.ArrayIterator<Data>, WizardDescriptor.AsynchronousInstantiatingIterator<Data>, WizardDescriptor.AsynchronousValidatingPanel<Data>, WizardDescriptor.BackgroundInstantiatingIterator<Data>, WizardDescriptor.ExtendedAsynchronousValidatingPanel<Data>, WizardDescriptor.FinishablePanel<Data>, WizardDescriptor.FinishPanel<Data>, WizardDescriptor.InstantiatingIterator<Data>, WizardDescriptor.Panel<Data>, WizardDescriptor.ProgressInstantiatingIterator<Data>, WizardDescriptor.ValidatingPanel<Data>
NotifyDescriptor.Confirmation, NotifyDescriptor.Exception, NotifyDescriptor.InputLine, NotifyDescriptor.Message
FINISH_OPTION, NEXT_OPTION, PREVIOUS_OPTION, PROP_AUTO_WIZARD_STYLE, PROP_CONTENT_BACK_COLOR, PROP_CONTENT_DATA, PROP_CONTENT_DISPLAYED, PROP_CONTENT_FOREGROUND_COLOR, PROP_CONTENT_NUMBERED, PROP_CONTENT_SELECTED_INDEX, PROP_ERROR_MESSAGE, PROP_HELP_DISPLAYED, PROP_HELP_URL, PROP_IMAGE, PROP_IMAGE_ALIGNMENT, PROP_INFO_MESSAGE, PROP_LEFT_DIMENSION, PROP_WARNING_MESSAGE
BOTTOM_ALIGN, DEFAULT_ALIGN, PROP_BUTTON_LISTENER, PROP_CLOSING_OPTIONS, PROP_HELP_CTX, PROP_LEAF, PROP_MODAL, PROP_OPTIONS_ALIGN, RIGHT_ALIGN
CANCEL_OPTION, CLOSED_OPTION, DEFAULT_OPTION, ERROR_MESSAGE, INFORMATION_MESSAGE, NO_OPTION, OK_CANCEL_OPTION, OK_OPTION, PLAIN_MESSAGE, PROP_DETAIL, PROP_ERROR_NOTIFICATION, PROP_INFO_NOTIFICATION, PROP_MESSAGE, PROP_MESSAGE_TYPE, PROP_NO_DEFAULT_CLOSE, PROP_OPTION_TYPE, PROP_OPTIONS, PROP_TITLE, PROP_VALID, PROP_VALUE, PROP_WARNING_NOTIFICATION, QUESTION_MESSAGE, WARNING_MESSAGE, YES_NO_CANCEL_OPTION, YES_NO_OPTION, YES_OPTION
Modifier | Constructor and Description |
---|---|
|
TemplateWizard()
Creates new TemplateWizard
|
protected |
TemplateWizard(TemplateWizard.Iterator it)
Constructor
for wizards that require the target chooser or template
chooser panel.
|
Modifier and Type | Method and Description |
---|---|
protected TemplateWizard.Iterator |
createDefaultIterator()
Allows subclasses to provide their own default iterator
the one that will be used if not special iterator is associated
with selected template.
|
protected WizardDescriptor.Panel<WizardDescriptor> |
createTargetChooser()
Method that allows subclasses to second (default) panel.
|
protected WizardDescriptor.Panel<WizardDescriptor> |
createTemplateChooser()
Method that allows subclasses to provide their own panel
for choosing the template (the first panel).
|
static URL |
getDescription(DataObject obj)
Method to get a description for a data object.
|
static String |
getDescriptionAsResource(DataObject obj)
Deprecated.
|
static TemplateWizard.Iterator |
getIterator(DataObject obj)
Finds a custom iterator attached to a template that should
be used to instantiate the object.
|
DataFolder |
getTargetFolder()
Getter for target folder.
|
String |
getTargetName()
Getter for the name of the target template.
|
DataObject |
getTemplate()
Getter for template to create object from.
|
DataFolder |
getTemplatesFolder()
Getter for the folder with templates.
|
MessageFormat |
getTitleFormat()
Overridden to be able to set a default value for the title format.
|
protected Set<DataObject> |
handleInstantiate()
Calls iterator's instantiate.
|
protected void |
initialize()
Initializes important settings.
|
Set<DataObject> |
instantiate()
Chooses the template and instantiates it.
|
Set<DataObject> |
instantiate(DataObject template)
Chooses the template and instantiates it.
|
Set<DataObject> |
instantiate(DataObject template,
DataFolder targetFolder)
Chooses the template and instantiates it.
|
static void |
setDescription(DataObject obj,
URL url)
Method to attach a description to a data object.
|
static void |
setDescriptionAsResource(DataObject obj,
String rsrc)
Deprecated.
|
static void |
setIterator(DataObject obj,
TemplateWizard.Iterator iter)
Deprecated.
since 2.13 you should provide the iterator from
getCookie method |
void |
setTargetFolder(DataFolder f)
Sets the target folder.
|
void |
setTargetName(String name)
Setter for the name of the template.
|
void |
setTemplate(DataObject obj)
Sets the template.
|
void |
setTemplatesFolder(DataFolder folder)
Setter for the folder with templates.
|
void |
setTitleFormat(MessageFormat format)
Overridden to be able to set own default value for the title format.
|
WizardDescriptor.Panel<WizardDescriptor> |
targetChooser()
Returns wizard panel that that is used to choose target folder and
name of the template.
|
WizardDescriptor.Panel<WizardDescriptor> |
templateChooser()
Returns wizard panel that is used to choose a template.
|
protected void |
updateState()
Overriden to add/remove listener to/from displayed component.
|
doCancelClick, doFinishClick, doNextClick, doPreviousClick, getInstantiatedObjects, getProperties, getProperty, getValue, putProperty, setAdditionalOptions, setClosingOptions, setHelpCtx, setOptions, setPanels, setPanelsAndSettings, setValue
getButtonListener, getClosingOptions, getHelpCtx, getOptionsAlign, isLeaf, isModal, setButtonListener, setLeaf, setModal, setOptionsAlign
addPropertyChangeListener, createNotificationLineSupport, firePropertyChange, getAdditionalOptions, getDefaultValue, getMessage, getMessageType, getNotificationLineSupport, getOptions, getOptionType, getTitle, getTitleForType, isNoDefaultClose, isValid, removePropertyChangeListener, setMessage, setMessageType, setNoDefaultClose, setOptionType, setTitle, setValid
public TemplateWizard()
protected TemplateWizard(TemplateWizard.Iterator it)
it
- panel iterator instanceprotected void initialize()
initialize
in class WizardDescriptor
public DataObject getTemplate()
public void setTemplate(DataObject obj)
obj
- the template to start withpublic void setTemplatesFolder(DataFolder folder)
folder
- the root folder for all templates if null the
default folder is usedpublic DataFolder getTemplatesFolder()
public DataFolder getTargetFolder() throws IOException
IOException
- if the target folder has not been setpublic void setTargetFolder(DataFolder f)
f
- the folderpublic String getTargetName()
null
if not yet setpublic void setTargetName(String name)
name
- name for the new object, or null
public WizardDescriptor.Panel<WizardDescriptor> templateChooser()
public WizardDescriptor.Panel<WizardDescriptor> targetChooser()
protected WizardDescriptor.Panel<WizardDescriptor> createTemplateChooser()
protected WizardDescriptor.Panel<WizardDescriptor> createTargetChooser()
protected TemplateWizard.Iterator createDefaultIterator()
This implementation creates iterator that just shows the targetChooser panel.
public Set<DataObject> instantiate() throws IOException
Beware that this blocks while the wizard is running;
and if a WizardDescriptor.BackgroundInstantiatingIterator
might be selected,
should not be called from the AWT event queue.
IOException
- I/O errorpublic Set<DataObject> instantiate(DataObject template) throws IOException
TemplateWizard.instantiate()
regarding threading behavior.template
- predefined template that should be instantiatedIOException
- I/O errorpublic Set<DataObject> instantiate(DataObject template, DataFolder targetFolder) throws IOException
TemplateWizard.instantiate()
regarding threading behavior.template
- predefined template that should be instantiatedtargetFolder
- the target folderIOException
- I/O errorpublic void setTitleFormat(MessageFormat format)
setTitleFormat
in class WizardDescriptor
format
- message formatpublic MessageFormat getTitleFormat()
getTitleFormat
in class WizardDescriptor
protected Set<DataObject> handleInstantiate() throws IOException
IOException
- if the instantiation failspublic static void setDescription(DataObject obj, URL url) throws IOException
nbresloc
protocol.obj
- data object to attach description tourl
- the url with description or null if there should be
no descriptionIOException
- if I/O failspublic static URL getDescription(DataObject obj)
obj
- data object to attach description to@Deprecated public static void setDescriptionAsResource(DataObject obj, String rsrc) throws IOException
TemplateWizard.setDescription(org.openide.loaders.DataObject, java.net.URL)
instead.obj
- data object to set description forrsrc
- a resource string, e.g. "com/foo/MyPage.html", or null
to clearIOException
- if the attribute cannot be set@Deprecated public static String getDescriptionAsResource(DataObject obj)
TemplateWizard.getDescription(org.openide.loaders.DataObject)
instead.obj
- the data objectnull
if unset (incl. if only set as a raw URL)@Deprecated public static void setIterator(DataObject obj, TemplateWizard.Iterator iter) throws IOException
getCookie
method
Better way for providing an Iterator is to return it from the
dataobject.getCookie (TemplateWizard.Iterator.class)
call.
obj
- data objectiter
- TemplateWizard.Iterator to use for instantiation of this
data object, or null
to clearIOException
- if I/O failspublic static TemplateWizard.Iterator getIterator(DataObject obj)
setIterator
method, if not it asks the
data object for the Iterator as cookie.obj
- the data objectprotected void updateState()
updateState
in class WizardDescriptor