org.openide.loaders
Class TemplateWizard

java.lang.Object
  |
  +--org.openide.NotifyDescriptor
        |
        +--org.openide.DialogDescriptor
              |
              +--org.openide.WizardDescriptor
                    |
                    +--org.openide.loaders.TemplateWizard

public class TemplateWizard
extends WizardDescriptor

Wizard for creation of new objects from a template.


Inner Class Summary
static interface TemplateWizard.Iterator
          The interface for custom iterator.
 
Inner classes inherited from class org.openide.WizardDescriptor
WizardDescriptor.ArrayIterator, WizardDescriptor.FinishPanel, WizardDescriptor.Iterator, WizardDescriptor.Panel
 
Inner classes inherited from class org.openide.NotifyDescriptor
NotifyDescriptor.Confirmation, NotifyDescriptor.Exception, NotifyDescriptor.InputLine, NotifyDescriptor.Message
 
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_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 requires 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)
          Allows to attach a special Iterator to a template.
 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()
          Panel that is used to choose target package and name of the template.
 WizardDescriptor.Panel templateChooser()
          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
getProperty, getValue, putProperty, setAdditionalOptions, setClosingOptions, setOptions, setPanels, setValue
 
Methods inherited from class org.openide.DialogDescriptor
getButtonListener, getClosingOptions, getHelpCtx, getOptionsAlign, isModal, setButtonListener, setHelpCtx, setModal, setOptionsAlign
 
Methods inherited from class org.openide.NotifyDescriptor
addPropertyChangeListener, firePropertyChange, getAdditionalOptions, 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 requires the target chooser or template chooser panel.
Parameters:
TemplateIterator.Iterator - iterator 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.

setTemplate

public void setTemplate(DataObject obj)
Sets the template. If under the TopManager.getPlaces ().folders (). 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 TopManager.getPlaces ().folders ().templates () 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. If the folder does not exists it is created at this point.
Returns:
the target folder
Throws:
IOException - if the possible creation of the folder fails

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

setTargetName

public void setTargetName(String name)
Setter for the name of the template.
Parameters:
name - name for the new object

templateChooser

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

targetChooser

public WizardDescriptor.Panel targetChooser()
Panel that is used to choose target package and name of the template.

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
Following copied from class: org.openide.WizardDescriptor
Parameters:
format - message format to the title

getTitleFormat

public MessageFormat getTitleFormat()
Overriden to be able to set a default value for the title format.
Overrides:
getTitleFormat in class WizardDescriptor
Following copied from class: org.openide.WizardDescriptor
Returns:
the format
See Also:
WizardDescriptor.setTitleFormat(java.text.MessageFormat)

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.

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

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
Allows to attach a special Iterator to a template. This allows templates to completelly control the way they are instantiated.
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.
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


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.