Class TemplateStorageManager
- java.lang.Object
-
- com.e1c.g5.v8.dt.lcore.ui.templates.TemplateStorageManager
-
public class TemplateStorageManager extends Object
Class to manageITemplateStorage
. One instance works with oneITemplateStorage
-
-
Constructor Summary
Constructors Constructor Description TemplateStorageManager(String storageID)
Creates instance of this that can manage storage with given IDTemplateStorageManager(String storageID, org.eclipse.core.runtime.preferences.IScopeContext scope)
Creates instance of this that can manage storage with given IDTemplateStorageManager(String storageID, org.eclipse.core.runtime.preferences.IScopeContext scope, TemplateStorageManager parent)
Creates instance of this that can manage storage with given ID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTemplate(ITemplate template)
Adds the given template or replaces added template with the same name as given with new onevoid
deserializeTemplateStorage(String jsonString)
Sets the content ofITemplateStorage
from given json-stringCollection<ITemplate>
getAllTemplates()
Gets all templates - union own templates from managed storage and parent storage.Collection<ITemplate>
getAllTemplates(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext context)
Return all templates that can be applied in the given contextprotected com.google.gson.GsonBuilder
getBuilder()
Return theGsonBuilder
to serialize/deserializeITemplateStorage
Collection<ITemplate>
getOwnTemplates()
Get own templates from managed storage.String
getTemplateStorageSerialized()
Returns json-string representation of the heldITemplateStorage
void
removeTemplate(ITemplate template)
Removes the given templatevoid
saveTemplateStorage()
Saves theITemplateStorage
-
-
-
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 benull
-
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 benull
scope
- The scope of the manager, cannot benull
-
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 benull
scope
- The scope of the manager, cannot benull
parent
- The parent manager of this manager to load storage from if current scope contains no data, can benull
. Empty template storage created if there is no data for given scope and parent isnull
-
-
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 benull
-
removeTemplate
public void removeTemplate(ITemplate template)
Removes the given template- Parameters:
template
- The template to remove, cannot benull
-
getOwnTemplates
public Collection<ITemplate> getOwnTemplates()
Get own templates from managed storage. Do not use this method for add or removeITemplate
from managed storage (seeaddTemplate(ITemplate)
orremoveTemplate(ITemplate)
).- Returns:
- own templates from managed storage, never
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 benull
- Returns:
- The collection of templates applicable in given context, cannot be
null
-
getTemplateStorageSerialized
public String getTemplateStorageSerialized()
Returns json-string representation of the heldITemplateStorage
- Returns:
- The json-string representation of the held
ITemplateStorage
, cannot benull
-
deserializeTemplateStorage
public void deserializeTemplateStorage(String jsonString)
Sets the content ofITemplateStorage
from given json-string- Parameters:
jsonString
- The json-string to get content from, cannot benull
-
saveTemplateStorage
public void saveTemplateStorage() throws org.osgi.service.prefs.BackingStoreException
Saves theITemplateStorage
- Throws:
org.osgi.service.prefs.BackingStoreException
- if save cannot be completed
-
getBuilder
protected com.google.gson.GsonBuilder getBuilder()
Return theGsonBuilder
to serialize/deserializeITemplateStorage
- Returns:
- builder for Gson that can be further configured, cannot be
null
-
-