Class TemplateEngine
- java.lang.Object
-
- org.eclipse.cdt.core.templateengine.TemplateEngine
-
- Direct Known Subclasses:
TemplateEngine2
public class TemplateEngine extends Object
TemplateEngine is implemented as a Singleton. TemplateEngine is responsible for creating SharedDefaults and initialising the SharedDefaults. Template instances are obtained from TemplateEngine.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description static String
TEMPLATE_ASSOCIATIONS_EXTENSION_ID
static String
TEMPLATES_EXTENSION_ID
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<Element>
getChildrenOfElement(Element element)
Returns the Children of the Element.static List<Element>
getChildrenOfElementByTag(Element element, String tag)
Returns the child elements by Tagstatic TemplateEngine
getDefault()
create the singleton instance, check for null condition of TEMPLATE_ENGINE.TemplateCore
getFirstTemplate(String projectType)
Equivalent to calling the overloaded version of getFirstTemplate with null arguments for toolChain and usageFilter.TemplateCore
getFirstTemplate(String projectType, String toolChain, String usageFilter)
Returns the first template defined for the specified parametersstatic Map<String,String>
getSharedDefaults()
TemplateCore
getTemplateById(String templateId)
Map<String,List<TemplateInfo>>
getTemplateInfoMap()
TemplateInfo[]
getTemplateInfos()
TemplateInfo[]
getTemplateInfos(String projectType)
TemplateInfo[]
getTemplateInfos(String projectType, String toolChain)
TemplateInfo[]
getTemplateInfos(String projectType, String toolChain, String usageFilter)
Gets an array of template info objects matching the criteria passed as parameters.TemplateCore[]
getTemplates()
Returns all the TemplateCore objects, no filtering is done.TemplateCore[]
getTemplates(String projectType)
TemplateCore[]
getTemplates(String projectType, String toolChain)
TemplateCore[]
getTemplates(String projectType, String toolChain, String usageFilter)
This method will be called by Container UIs (Wizard, PropertyPage, PreferencePage).URL
getTemplateSchemaURL()
Returns the Template Schema URLvoid
updateSharedDefaults(TemplateCore template)
update The SharedDefaults Map.
-
-
-
Method Detail
-
getTemplates
public TemplateCore[] getTemplates()
Returns all the TemplateCore objects, no filtering is done.
-
getFirstTemplate
public TemplateCore getFirstTemplate(String projectType, String toolChain, String usageFilter)
Returns the first template defined for the specified parameters- Parameters:
projectType
- may not be nulltoolChain
- may be null to indicate no tool-chain filteringusageFilter
- a regex in java.util.regex.Pattern format, may be null to indicate no filtering- Returns:
- the TemplateCore for the first template defined for the specified parameters, or null if no such definition exists, or if there is an error initializing the template (the error will be logged).
- See Also:
Pattern
-
getFirstTemplate
public TemplateCore getFirstTemplate(String projectType)
Equivalent to calling the overloaded version of getFirstTemplate with null arguments for toolChain and usageFilter.- Returns:
- the first TemplateCore object registered, or null if this does not exist
- See Also:
getFirstTemplate(String, String, String)
-
getTemplates
public TemplateCore[] getTemplates(String projectType, String toolChain, String usageFilter)
This method will be called by Container UIs (Wizard, PropertyPage, PreferencePage). Create a Template instance, update the ValueStore, with SharedDefaults. This method calls the getTemplate(URL), after getting URL for the given String TemplateDescriptor.
-
getTemplates
public TemplateCore[] getTemplates(String projectType, String toolChain)
-
getTemplates
public TemplateCore[] getTemplates(String projectType)
-
getTemplateById
public TemplateCore getTemplateById(String templateId)
-
getSharedDefaults
public static Map<String,String> getSharedDefaults()
- Returns:
- the SharedDefaults.
-
updateSharedDefaults
public void updateSharedDefaults(TemplateCore template)
update The SharedDefaults Map. This method will be called by Container UIs. After collecting data from UIPages, the IDs with Persist attribute as true, has to be persisted in SharedDefaults XML. For the same this method is called by passing the ValueStore(updated with user entered values). Get the PersistTrueIDs from TemplateDescriptor. Persist the values of IDs in ValueStore, which are also present in PersistTrueIDs vector.- Parameters:
template
-
-
getDefault
public static TemplateEngine getDefault()
create the singleton instance, check for null condition of TEMPLATE_ENGINE. If TEMPLATE_ENGINE is null create the TemplateEngine instance assign it to TEMPLATE_ENGINE. There is no need to have synchronized here(while creating TemplateEngine).- Returns:
- TEMPLATE_ENGINE, instance of TemplateEngine.
- Since:
- 4.0
-
getTemplateInfos
public TemplateInfo[] getTemplateInfos(String projectType, String toolChain, String usageFilter)
Gets an array of template info objects matching the criteria passed as parameters.- Parameters:
projectType
- may not be nulltoolChain
- may be null to indicate no tool-chainusageFilter
- a usage string which is matched against the filter from the template, may be null to indicate no usage filtering- Returns:
- an array of TemplateInfo objects (never null)
-
getTemplateInfos
public TemplateInfo[] getTemplateInfos(String projectType, String toolChain)
-
getTemplateInfos
public TemplateInfo[] getTemplateInfos(String projectType)
-
getTemplateInfos
public TemplateInfo[] getTemplateInfos()
- Returns:
- all TemplateInfo objects known to the TemplateEngine
-
getTemplateInfoMap
public Map<String,List<TemplateInfo>> getTemplateInfoMap()
- Returns:
- the map from project-type ID's to all associated TemplateInfo instances
-
getTemplateSchemaURL
public URL getTemplateSchemaURL() throws IOException
Returns the Template Schema URL- Returns:
- URL of the Template Schema.
- Throws:
IOException
-
getChildrenOfElement
public static List<Element> getChildrenOfElement(Element element)
Returns the Children of the Element.- Parameters:
element
-- Returns:
- List of the child elements
- Since:
- 4.0
-
-