站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.5.1

TemplateWizard (NetBeans Loaders API) - NetBeans API Javadoc 5.5.1

org.openide.loaders 5.9.31

org.openide.loaders
Class TemplateWizard

java.lang.Object
  extended by org.openide.NotifyDescriptor
      extended by org.openide.DialogDescriptor
          extended by org.openide.WizardDescriptor
              extended by org.openide.loaders.TemplateWizard
All Implemented Interfaces:
HelpCtx.Provider

public class TemplateWizard
extends WizardDescriptor

Wizard for creation of new objects from a template.


Nested Class Summary
static interface TemplateWizard.Iterator
          The interface for custom iterator.
 
Nested classes/interfaces inherited from class org.openide.WizardDescriptor
WizardDescriptor.ArrayIterator, WizardDescriptor.AsynchronousInstantiatingIterator, WizardDescriptor.AsynchronousValidatingPanel, WizardDescriptor.FinishablePanel, WizardDescriptor.FinishPanel, WizardDescriptor.InstantiatingIterator, WizardDescriptor.Panel, WizardDescriptor.ValidatingPanel
 
Nested classes/interfaces inherited from class org.openide.NotifyDescriptor
NotifyDescriptor.Confirmation, NotifyDescriptor.Exception, NotifyDescriptor.InputLine, NotifyDescriptor.Message
 
Field Summary
 
Fields inherited from class org.openide.WizardDescriptor
FINISH_OPTION, NEXT_OPTION, PREVIOUS_OPTION
 
Fields inherited from class org.openide.DialogDescriptor
BOTTOM_ALIGN, DEFAULT_ALIGN, PROP_BUTTON_LISTENER, PROP_CLOSING_OPTIONS, PROP_HELP_CTX, PROP_LEAF, PROP_MODAL, PROP_OPTIONS_ALIGN, RIGHT_ALIGN
 
Fields inherited from class org.openide.NotifyDescriptor
CANCEL_OPTION, CLOSED_OPTION, DEFAULT_OPTION, ERROR_MESSAGE, INFORMATION_MESSAGE, NO_OPTION, OK_CANCEL_OPTION, OK_OPTION, PLAIN_MESSAGE, PROP_DETAIL, PROP_MESSAGE, PROP_MESSAGE_TYPE, PROP_OPTION_TYPE, PROP_OPTIONS, PROP_TITLE, PROP_VALID, PROP_VALUE, QUESTION_MESSAGE, WARNING_MESSAGE, YES_NO_CANCEL_OPTION, YES_NO_OPTION, YES_OPTION
 
Constructor Summary
  TemplateWizard()
          Creates new TemplateWizard
protected TemplateWizard(TemplateWizard.Iterator it)
          Constructor for wizards that require the target chooser or template chooser panel.
 
Method Summary
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 createTargetChooser()
          Method that allows subclasses to second (default) panel.
protected  WizardDescriptor.Panel 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. Use getDescription(org.openide.loaders.DataObject) instead.
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()
          Overriden to be able to set a default value for the title format.
protected  Set handleInstantiate()
          Calls iterator's instantiate.
protected  void initialize()
          Initializes important settings.
 Set instantiate()
          Chooses the template and instantiates it.
 Set instantiate(DataObject template)
          Chooses the template and instantiates it.
 Set 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. Use setDescription(org.openide.loaders.DataObject, java.net.URL) instead.
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)
          Overriden to be able to set own default value for the title format.
 WizardDescriptor.Panel targetChooser()
          Returns wizard panel that that is used to choose target folder and name of the template.
 WizardDescriptor.Panel templateChooser()
          Returns wizard panel that is used to choose a template.
protected  void updateState()
          Overriden to add/remove listener to/from displayed component.
 
Methods inherited from class org.openide.WizardDescriptor
getInstantiatedObjects, getProperty, getValue, putProperty, setAdditionalOptions, setClosingOptions, setHelpCtx, setOptions, setPanels, setValue
 
Methods inherited from class org.openide.DialogDescriptor
getButtonListener, getClosingOptions, getHelpCtx, getOptionsAlign, isLeaf, isModal, setButtonListener, setLeaf, setModal, setOptionsAlign
 
Methods inherited from class org.openide.NotifyDescriptor
addPropertyChangeListener, firePropertyChange, getAdditionalOptions, getDefaultValue, getMessage, getMessageType, getOptions, getOptionType, getTitle, getTitleForType, isValid, removePropertyChangeListener, setMessage, setMessageType, setOptionType, setTitle, setValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateWizard

public TemplateWizard()
Creates new TemplateWizard


TemplateWizard

protected TemplateWizard(TemplateWizard.Iterator it)
Constructor for wizards that require the target chooser or template chooser panel.

Parameters:
it - panel iterator instance
Method Detail

initialize

protected void initialize()
Initializes important settings.

Overrides:
initialize in class WizardDescriptor

getTemplate

public DataObject getTemplate()
Getter for template to create object from.

Returns:
template

setTemplate

public void setTemplate(DataObject obj)
Sets the template. If under the Templates/ directory it will be selected by the dialog.

Parameters:
obj - the template to start with

setTemplatesFolder

public void setTemplatesFolder(DataFolder folder)
Setter for the folder with templates. If not specified the Templates/ folder is used.

Parameters:
folder - the root folder for all templates if null the default folder is used

getTemplatesFolder

public DataFolder getTemplatesFolder()
Getter for the folder with templates.

Returns:
the folder with templates that should be used as root

getTargetFolder

public DataFolder getTargetFolder()
                           throws IOException
Getter for target folder.

Returns:
the target folder
Throws:
IOException - if the target folder has not been set

setTargetFolder

public void setTargetFolder(DataFolder f)
Sets the target folder.

Parameters:
f - the folder

getTargetName

public String getTargetName()
Getter for the name of the target template.

Returns:
the name or null if not yet set

setTargetName

public void setTargetName(String name)
Setter for the name of the template.

Parameters:
name - name for the new object, or null

templateChooser

public WizardDescriptor.Panel templateChooser()
Returns wizard panel that is used to choose a template.

Returns:
wizard panel

targetChooser

public WizardDescriptor.Panel targetChooser()
Returns wizard panel that that is used to choose target folder and name of the template.

Returns:
wizard panel

createTemplateChooser

protected WizardDescriptor.Panel createTemplateChooser()
Method that allows subclasses to provide their own panel for choosing the template (the first panel).

Returns:
the panel

createTargetChooser

protected WizardDescriptor.Panel createTargetChooser()
Method that allows subclasses to second (default) panel.

Returns:
the panel

createDefaultIterator

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.

This implementation creates iterator that just shows the targetChooser panel.

Returns:
the iterator to use as default one

instantiate

public Set instantiate()
                throws IOException
Chooses the template and instantiates it.

Returns:
set of instantiated data objects (DataObject) or null if user canceled the dialog
Throws:
IOException - I/O error

instantiate

public Set instantiate(DataObject template)
                throws IOException
Chooses the template and instantiates it.

Parameters:
template - predefined template that should be instantiated
Returns:
set of instantiated data objects (DataObject) or null if user canceled the dialog
Throws:
IOException - I/O error

instantiate

public Set instantiate(DataObject template,
                       DataFolder targetFolder)
                throws IOException
Chooses the template and instantiates it.

Parameters:
template - predefined template that should be instantiated
targetFolder - the target folder
Returns:
set of instantiated data objects (DataObject) or null if user canceled the dialog
Throws:
IOException - I/O error

setTitleFormat

public void setTitleFormat(MessageFormat format)
Overriden to be able to set own default value for the title format.

Overrides:
setTitleFormat in class WizardDescriptor
Parameters:
format - message format

getTitleFormat

public MessageFormat getTitleFormat()
Overriden to be able to set a default value for the title format.

Overrides:
getTitleFormat in class WizardDescriptor
Returns:
message format in title

handleInstantiate

protected Set handleInstantiate()
                         throws IOException
Calls iterator's instantiate. It is called when user selects a option which is not CANCEL_OPTION or CLOSED_OPTION.

Returns:
set of data objects that have been created (should contain at least one)
Throws:
IOException - if the instantiation fails

setDescription

public static void setDescription(DataObject obj,
                                  URL url)
                           throws IOException
Method to attach a description to a data object. It is suggested that the URL use the nbresloc protocol.

Parameters:
obj - data object to attach description to
url - the url with description or null if there should be no description
Throws:
IOException - if I/O fails

getDescription

public static URL getDescription(DataObject obj)
Method to get a description for a data object.

Parameters:
obj - data object to attach description to
Returns:
the url with description or null

setDescriptionAsResource

public static void setDescriptionAsResource(DataObject obj,
                                            String rsrc)
                                     throws IOException
Deprecated. Use setDescription(org.openide.loaders.DataObject, java.net.URL) instead.

Set a description for a data object by resource path rather than raw URL.

Parameters:
obj - data object to set description for
rsrc - a resource string, e.g. "com/foo/MyPage.html", or null to clear
Throws:
IOException - if the attribute cannot be set

getDescriptionAsResource

public static String getDescriptionAsResource(DataObject obj)
Deprecated. Use getDescription(org.openide.loaders.DataObject) instead.

Get a description as a resource.

Parameters:
obj - the data object
Returns:
the resource path, or null if unset (incl. if only set as a raw URL)

setIterator

public static void setIterator(DataObject obj,
                               TemplateWizard.Iterator iter)
                        throws IOException
Deprecated. since 2.13 you should provide the iterator from getCookie method

Allows to attach a special Iterator to a template. This allows templates to completelly control the way they are instantiated.

Better way for providing an Iterator is to return it from the dataobject.getCookie (TemplateWizard.Iterator.class) call.

Parameters:
obj - data object
iter - TemplateWizard.Iterator to use for instantiation of this data object, or null to clear
Throws:
IOException - if I/O fails

getIterator

public static TemplateWizard.Iterator getIterator(DataObject obj)
Finds a custom iterator attached to a template that should be used to instantiate the object. First of all it checks whether there is an iterator attached by setIterator method, if not it asks the data object for the Iterator as cookie.

Parameters:
obj - the data object
Returns:
custom iterator or null

updateState

protected void updateState()
Overriden to add/remove listener to/from displayed component. Also make recreation of steps and content.

Overrides:
updateState in class WizardDescriptor

org.openide.loaders 5.9.31

Built on March 26 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.