Class TemplateStorageManager

    • Constructor Detail

      • TemplateStorageManager

        public TemplateStorageManager​(String storageID)
        Creates instance of this that can manage storage with given ID
        Parameters:
        storageID - The ID of the storage, cannot be null
      • TemplateStorageManager

        public TemplateStorageManager​(String storageID,
                                      org.eclipse.core.runtime.preferences.IScopeContext scope)
        Creates instance of this that can manage storage with given ID
        Parameters:
        storageID - The ID of the storage, cannot be null
        scope - The scope of the manager, cannot be null
      • TemplateStorageManager

        public TemplateStorageManager​(String storageID,
                                      org.eclipse.core.runtime.preferences.IScopeContext scope,
                                      TemplateStorageManager parent)
        Creates instance of this that can manage storage with given ID
        Parameters:
        storageID - The ID of the storage, cannot be null
        scope - The scope of the manager, cannot be null
        parent - The parent manager of this manager to load storage from if current scope contains no data, can be null. Empty template storage created if there is no data for given scope and parent is null
    • Method Detail

      • addTemplate

        public void addTemplate​(ITemplate template)
        Adds the given template or replaces added template with the same name as given with new one
        Parameters:
        template - The template to save, cannot be null
      • removeTemplate

        public void removeTemplate​(ITemplate template)
        Removes the given template
        Parameters:
        template - The template to remove, cannot be null
      • getAllTemplates

        public Collection<ITemplate> getAllTemplates()
        Gets all templates - union own templates from managed storage and parent storage.
        Returns:
        all templates - union own templates from managed storage and parent storage, never null
      • getAllTemplates

        public Collection<ITemplate> getAllTemplates​(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext context)
        Return all templates that can be applied in the given context
        Parameters:
        context - The context to check, cannot be null
        Returns:
        The collection of templates applicable in given context, cannot be null
      • getTemplateStorageSerialized

        public String getTemplateStorageSerialized()
        Returns json-string representation of the held ITemplateStorage
        Returns:
        The json-string representation of the held ITemplateStorage, cannot be null
      • deserializeTemplateStorage

        public void deserializeTemplateStorage​(String jsonString)
        Sets the content of ITemplateStorage from given json-string
        Parameters:
        jsonString - The json-string to get content from, cannot be null
      • saveTemplateStorage

        public void saveTemplateStorage()
                                 throws org.osgi.service.prefs.BackingStoreException
        Throws:
        org.osgi.service.prefs.BackingStoreException - if save cannot be completed
      • getBuilder

        protected com.google.gson.GsonBuilder getBuilder()
        Return the GsonBuilder to serialize/deserialize ITemplateStorage
        Returns:
        builder for Gson that can be further configured, cannot be null