Class 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 Detail

      • TEMPLATES_EXTENSION_ID

        public static String TEMPLATES_EXTENSION_ID
      • TEMPLATE_ASSOCIATIONS_EXTENSION_ID

        public static String TEMPLATE_ASSOCIATIONS_EXTENSION_ID
    • 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 null
        toolChain - may be null to indicate no tool-chain filtering
        usageFilter - 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.
      • 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 null
        toolChain - may be null to indicate no tool-chain
        usageFilter - 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()
        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
      • getChildrenOfElementByTag

        public static List<Element> getChildrenOfElementByTag​(Element element,
                                                              String tag)
        Returns the child elements by Tag
        Parameters:
        element -
        tag -
        Returns:
        List of child elements
        Since:
        4.0