public abstract class AbstractTemplateSection extends Object implements ITemplateSection, IVariableProvider
Modifier and Type | Field and Description |
---|---|
static String |
KEY_ACTIVATOR_SIMPLE
The key for the simple class name of a bundle activator (value="activator")
|
static String |
KEY_PACKAGE_NAME
The key for the package name that will be created by this template
(value="packageName").
|
static String |
KEY_PLUGIN_CLASS
The key for the main plug-in class of the plug-in that the template is
used for (value="pluginClass").
|
static String |
KEY_PLUGIN_ID
The key for the plug-in id of the plug-in that the template is used for
(value="pluginId").
|
static String |
KEY_PLUGIN_NAME
The key for the plug-in name of the plug-in that the template is used for
(value="pluginName").
|
protected IPluginModelBase |
model
The plug-in model.
|
protected IProject |
project
The project handle.
|
Constructor and Description |
---|
AbstractTemplateSection() |
Modifier and Type | Method and Description |
---|---|
void |
addPages(Wizard wizard)
Adds template-related pages to the wizard.
|
protected IPluginExtension |
createExtension(String pointId,
boolean reuse)
A utility method to create an extension object for the plug-in model from
the provided extension point id.
|
void |
execute(IProject project,
IPluginModelBase model,
IProgressMonitor monitor)
The default implementation of the interface method.
|
protected void |
generateFiles(IProgressMonitor monitor)
Generates files as part of the template execution.
|
protected void |
generateFiles(IProgressMonitor monitor,
URL locationUrl)
Generates files as part of the template execution.
|
IPluginReference[] |
getDependencies(String schemaVersion)
Provides the list of template dependencies.
|
String |
getDescription()
Returns a description of the section.
|
protected String |
getManifestHeader(String name)
Gets a header from within the plug-in's underlying manifest header, if it
has one.
|
int |
getNumberOfWorkUnits()
The default implementation of the interface method.
|
boolean |
getPagesAdded()
Tests if wizard pages for this template section have been added.
|
protected abstract ResourceBundle |
getPluginResourceBundle()
An abstract method that returns the resource bundle that corresponds to
the best match of plugin.properties file for the current
locale (in case of fragments, the file is fragment.properties
).
|
String |
getPluginResourceString(String key)
Returns the translated version of the resource string represented by the
provided key.
|
String |
getReplacementString(String fileName,
String key)
The default implementation of this method provides values of the
following keys: pluginClass , pluginId and
pluginName .
|
protected IFolder |
getSourceFolder(IProgressMonitor monitor)
Returns the folder with Java files in the target project.
|
protected double |
getTargetVersion() |
URL |
getTemplateLocation()
Returns the URL of the zip file containing template files and directories
that will be created in the plug-in project.
|
Object |
getValue(String key)
Returns the value of the variable with a given name.
|
protected boolean |
hasBundleManifest()
Determines whether this plug-in has a manifest on which to set/get
headers.
|
protected boolean |
isOkToCreateFile(File sourceFile)
Tests if the file found in the template location should be created in the
target project.
|
protected boolean |
isOkToCreateFolder(File sourceFolder)
Tests if the folder found in the template location should be created in
the target project.
|
protected void |
markPagesAdded()
Marks that pages have been added to the wizard by this template.
|
protected void |
setManifestHeader(String name,
String value)
Sets a header within the plug-in's underlying manifest header, if it has
one.
|
protected abstract void |
updateModel(IProgressMonitor monitor)
Subclass must implement this method to add the required entries in the
plug-in model.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLabel, getNewFiles, getPage, getPageCount, getUsedExtensionPoint
protected IProject project
protected IPluginModelBase model
public static final String KEY_PLUGIN_CLASS
public static final String KEY_ACTIVATOR_SIMPLE
public static final String KEY_PLUGIN_ID
public static final String KEY_PLUGIN_NAME
public static final String KEY_PACKAGE_NAME
public String getReplacementString(String fileName, String key)
getReplacementString
in interface ITemplateSection
fileName
- the name of the file in which the key was found. You can use
it to return different values for different files.key
- the replacement key found in the template fileITemplateSection.getReplacementString(String,String)
public Object getValue(String key)
IVariableProvider
getValue
in interface IVariableProvider
key
- the name of the variableIVariableProvider.getValue(String)
public URL getTemplateLocation()
ITemplateSection
getTemplateLocation
in interface ITemplateSection
ITemplateSection.getTemplateLocation()
public String getDescription()
ITemplateSection
getDescription
in interface ITemplateSection
ITemplateSection.getDescription()
public String getPluginResourceString(String key)
key
- the key of the required resource stringgetPluginResourceBundle()
protected abstract ResourceBundle getPluginResourceBundle()
public void addPages(Wizard wizard)
ITemplateSection
addPages
in interface ITemplateSection
wizard
- the host wizard to add pages intopublic boolean getPagesAdded()
getPagesAdded
in interface ITemplateSection
true
if wizard pages for this section have been
added, false
otherwise.protected void markPagesAdded()
addPages(Wizard)
public int getNumberOfWorkUnits()
getNumberOfWorkUnits
in interface ITemplateSection
ITemplateSection.getNumberOfWorkUnits()
public IPluginReference[] getDependencies(String schemaVersion)
ITemplateSection
getDependencies
in interface ITemplateSection
schemaVersion
- version of the target manifest, or null if older
manifest (prior to 3.0) will be created. Depending on the
manifest version, the list of dependencies may vary.protected IFolder getSourceFolder(IProgressMonitor monitor)
monitor
- progress monitor to useprotected void generateFiles(IProgressMonitor monitor) throws CoreException
generateFiles(IProgressMonitor monitor, URL locationUrl)
on how
the location gets processed.monitor
- progress monitor to use to indicate generation progressCoreException
protected void generateFiles(IProgressMonitor monitor, URL locationUrl) throws CoreException
monitor
- progress monitor to use to indicate generation progresslocationUrl
- a url pointing to a file/directory that will be copied into the templateCoreException
protected boolean isOkToCreateFolder(File sourceFolder)
sourceFolder
- the folder that is testedtrue
if the provided folder should be created in
the workspace, false
if the values of the
substitution variables indicate otherwise.protected boolean isOkToCreateFile(File sourceFile)
sourceFile
- the file found in the template location that needs to be
created.protected abstract void updateModel(IProgressMonitor monitor) throws CoreException
monitor
- the progress monitor to be usedCoreException
public void execute(IProject project, IPluginModelBase model, IProgressMonitor monitor) throws CoreException
execute
in interface ITemplateSection
project
- the workspace project that contains the plug-inmodel
- structured representation of the plug-in manifestmonitor
- progress monitor to indicate execution progressCoreException
- if there is a problem generating resourcesITemplateSection.execute(IProject, IPluginModelBase,
IProgressMonitor)
protected IPluginExtension createExtension(String pointId, boolean reuse) throws CoreException
pointId
- the identifier of the target extension pointreuse
- if true, new extension object will be created only if an
extension with the same Id does not exist.CoreException
protected double getTargetVersion()
protected void setManifestHeader(String name, String value)
name
- The name of the header to setvalue
- The value of the headerConstants
protected String getManifestHeader(String name)
name
- The name of the header to fetchprotected boolean hasBundleManifest()
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.