Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse PDE Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.pde.ui.templates
Class BaseOptionTemplateSection

    java.lang.Object
      org.eclipse.pde.ui.templates.AbstractTemplateSection
          org.eclipse.pde.ui.templates.BaseOptionTemplateSection

All Implemented Interfaces:
  ITemplateSection, IVariableProvider

Direct Known Subclasses:
  OptionTemplateSection

public abstract class BaseOptionTemplateSection
extends AbstractTemplateSection

This class adds a notion of options to the default template section implementation. Options have values and visual presence that allows users to change them. When a section is configured with a number of options, they become available to the code generator and can take part in conditional code emitting.

This class is typically used in conjunction with `OptionTemplateWizardPage` . The later is capable of creating UI based on the list of options it was given, thus simplifying new template section creation.

Since:
  2.0

Field Summary

Fields inherited from class org.eclipse.pde.ui.templates.AbstractTemplateSection
`KEY_PACKAGE_NAME, KEY_PLUGIN_CLASS, KEY_PLUGIN_ID, KEY_PLUGIN_NAME, model, project`

Constructor Summary
`BaseOptionTemplateSection()`

Method Summary
`protected TemplateOption` | `addOption(String name, String label, boolean value, int pageIndex)` Adds a boolean option with a provided name, label and initial value.
`protected TemplateOption` | `addOption(String name, String label, String[][] choices, String value, int pageIndex)` Adds a choice option with a provided name, label, list of choices and the initial value (choice).
`protected TemplateOption` | `addOption(String name, String label, String value, int pageIndex)` Adds a string option with a provided name, label and initial value.
`void` | `execute(IProject project, IPluginModelBase model, IProgressMonitor monitor)` Modifies the superclass implementation by adding the initialization step before commencing execution.
`boolean` | `getBooleanOption(String key)` Returns a boolean value of the option with a given name.
`String` | `getReplacementString(String fileName, String key)` Expands variable substitution to include all string options defined in this template.
`String` | `getStringOption(String name)` Returns a string value of the option with a given name.
`Object` | `getValue(String name)` Returns the value of the option with a given name.
`protected void` | `initializeFields(IFieldData data)` Initializes options in the wizard page using the data provided by the method parameters.
`void` | `initializeFields(IPluginModelBase model)` Initializes options in the wizard page using the data provided by the method parameters.
`protected void` | `initializeOption(String name, Object value)` Initializes the option with a given unique name with the provided value.
`boolean` | `isDependentOnParentWizard()` Returns true if this template depends on values set in the parent wizard.
`protected void` | `registerOption(TemplateOption option, Object value, int pageIndex)` Registers the provided option and sets the initial value.
`void` | `setOptionEnabled(String name, boolean enabled)` Enables the option with a given name.
`abstract void` | `validateOptions(TemplateOption changed)` Subclasses must implement this method in order to validate options whose value have been changed by the user.

Methods inherited from class org.eclipse.pde.ui.templates.AbstractTemplateSection
`addPages, createExtension, generateFiles, getDependencies, getDescription, getNumberOfWorkUnits, getPagesAdded, getPluginResourceBundle, getPluginResourceString, getSourceFolder, getTemplateLocation, isOkToCreateFile, isOkToCreateFolder, markPagesAdded, updateModel`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.eclipse.pde.ui.templates.ITemplateSection
`getLabel, getNewFiles, getPage, getPageCount, getUsedExtensionPoint`

Constructor Detail

### BaseOptionTemplateSection

    public BaseOptionTemplateSection()

Method Detail

### addOption

    protected TemplateOption addOption(String name,
                                       String label,
                                       boolean value,
                                       int pageIndex)

  Adds a boolean option with a provided name, label and initial value.

  Parameters:
    `name` - the unique name of the option (can be used as a variable in conditional code emitting and variable substitution)
    `label` - presentable name of the option
    `value` - initial value of the option
    `pageIndex` - a zero-based index of a page where this option should appear
  Returns:
    the newly created option

### addOption

    protected TemplateOption addOption(String name,
                                       String label,
                                       String value,
                                       int pageIndex)

  Adds a string option with a provided name, label and initial value.

  Parameters:
    `name` - the unique name of the option (can be used as a variable in conditional code emitting and variable substitution)
    `label` - presentable name of the option
    `value` - initial value of the option
    `pageIndex` - a zero-based index of a page where this option should appear
  Returns:
    the newly created option

### addOption

    protected TemplateOption addOption(String name,
                                       String label,
                                       String[][] choices,
                                       String value,
                                       int pageIndex)

  Adds a choice option with a provided name, label, list of choices and the initial value (choice).

  Parameters:
    `name` - the unique name of the option (can be used as a variable in conditional code emitting and variable substitution)
    `label` - presentable name of the option
    `choices` - an array of choices that the user will have when setting the value of the option. Each array position should accept an array of String objects of size 2, the first being the unique name and the second the presentable label of the choice.
    `value` - initial value (choice) of the option
    `pageIndex` - a zero-based index of a page where this option should appear
  Returns:
    the newly created option

### initializeOption

    protected void initializeOption(String name,
                                    Object value)

  Initializes the option with a given unique name with the provided value. The value will be set only if the option has not yet been initialized.

  Parameters:
    `name` - option unique name
    `value` - the initial value of the option

### getStringOption

    public String getStringOption(String name)

  Returns a string value of the option with a given name. The option with that name must exist and must be registered as a string option to begin with.

  Parameters:
    `name` - the unique name of the option
  Returns:
    the string value of the option with a given name or `null` if not found.

### getBooleanOption

    public boolean getBooleanOption(String key)

  Returns a boolean value of the option with a given name. The option with that name must exist and must be registered as a boolean option to begin with.

  Returns:
    the boolean value of the option with a given name or `null` if not found.

### setOptionEnabled

    public void setOptionEnabled(String name,
                                 boolean enabled)

  Enables the option with a given name. The exact effect of the method depends on the option type, but the end-result should always be the same - users should not be able to modify values of disabled options. This method has no effect if the option with a given name is not found.

  Parameters:
    `name` - the unique name of the option
    `enabled` - the enable state that the option should have

### getValue

    public Object getValue(String name)

  Returns the value of the option with a given name. The actual type of the returned object depends on the option type.

  Specified by:
    `getValue` in interface `IVariableProvider`
  Overrides:
    `getValue` in class `AbstractTemplateSection`
  Parameters:
    `name` - the name of the option
  Returns:
    the current value of the option with a specified name or `null` if not found or not applicable.
  See Also:
    `IVariableProvider.getValue(String)`

### isDependentOnParentWizard

    public boolean isDependentOnParentWizard()

  Returns true if this template depends on values set in the parent wizard. Values in the parent wizard include plug-in id, plug-in name, plug-in class name, plug-in provider etc. If the template does depend on these values, `initializeFields` will be called when the page is made visible in the forward direction (going from the first page to the pages owned by this template). If the page is never shown (Finish is pressed before the page is made visible at least once), `initializeFields` will be called with the model object instead during template execution. The same method will also be called when the template is created within the context of the plug-in manifest editor, because plug-in model already exists at that time.

  Returns:
    `true` if this template depends on the data set in the parent wizard, `false` otherwise.

### initializeFields

    protected void initializeFields(IFieldData data)

  Initializes options in the wizard page using the data provided by the method parameters. Some options may depend on the user selection in the common wizard pages before template page has been shown (for example, plug-in ID, plug-in name etc.). This method allows options to initialize in respect to these values.

  The method is called before the actual plug-in has been built.

  Parameters:
    `data` - plug-in data as defined in the common plug-in project wizard pages

### initializeFields

    public void initializeFields(IPluginModelBase model)

  Initializes options in the wizard page using the data provided by the method parameters. Some options may depend on the user selection in the common wizard pages before template page has been shown (for example, plug-in ID, plug-in name etc.). This method allows options to initialize in respect to these values.

  This method is called after the plug-in has already been created or as part of new extension creation (inside the manifest editor). Either way, the plug-in properties in the model have been fully set and the model can be used to initialize options that cannot be initialized independently.

  Parameters:
    `model` - the model of the plug-in manifest file.

### validateOptions

    public abstract void validateOptions(TemplateOption changed)

  Subclasses must implement this method in order to validate options whose value have been changed by the user. The subclass can elect to validate the option on its own, or to also check validity of other options in relation to the new value of this one.

  Parameters:
    `changed` - the option whose value has been changed by the user

### getReplacementString

    public String getReplacementString(String fileName,
                                       String key)

  Expands variable substitution to include all string options defined in this template.

  Specified by:
    `getReplacementString` in interface `ITemplateSection`
  Overrides:
    `getReplacementString` in class `AbstractTemplateSection`
  See Also:
    `AbstractTemplateSection.getReplacementString(String, String)`

### execute

    public void execute(IProject project,
                        IPluginModelBase model,
                        IProgressMonitor monitor)
                 throws CoreException

  Modifies the superclass implementation by adding the initialization step before commencing execution. This is important because some options may not be initialized and users may choose to press 'Finish' before the wizard page where the options are were shown for the first time.

  Specified by:
    `execute` in interface `ITemplateSection`
  Overrides:
    `execute` in class `AbstractTemplateSection`
  Throws:
    `CoreException`
  See Also:
    `ITemplateSection.execute(IProject, IPluginModelBase, IProgressMonitor)`

### registerOption

    protected void registerOption(TemplateOption option,
                                  Object value,
                                  int pageIndex)

  Registers the provided option and sets the initial value.

  Parameters:
    `option` - the option to register
    `value` - the initial value
    `pageIndex` - the page index to which this option belongs

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse PDE Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.