Class TemplateStore
- java.lang.Object
-
- org.eclipse.text.templates.TemplateStoreCore
-
- org.eclipse.jface.text.templates.persistence.TemplateStore
-
- Direct Known Subclasses:
ContributionTemplateStore
public class TemplateStore extends org.eclipse.text.templates.TemplateStoreCoreA collection of templates. Clients may instantiate this class. In order to load templates contributed using theorg.eclipse.ui.editors.templatesextension point, use aContributionTemplateStore.- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description TemplateStore(IPreferenceStore store, String key)Creates a new template store.TemplateStore(ContextTypeRegistry registry, IPreferenceStore store, String key)Creates a new template store with a context type registry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(TemplatePersistenceData data)voiddelete(TemplatePersistenceData data)protected ContextTypeRegistrygetRegistry()Returns the registry.TemplatePersistenceData[]getTemplateData(boolean includeDeleted)Returns all template data.TemplatePersistenceDatagetTemplateData(String id)Returns the template data of the template with ididornullif no such template can be found.protected voidinternalAdd(TemplatePersistenceData data)voidload()Loads the templates from contributions and preferences.voidrestoreDefaults(boolean doSave)Deletes all user-added templates and reverts all contributed templates.voidsave()Saves the templates to the preferences.voidstartListeningForPreferenceChanges()Starts listening for property changes on the preference store.voidstopListeningForPreferenceChanges()Stops the auto-updating behavior started by callingstartListeningForPreferenceChanges().
-
-
-
Constructor Detail
-
TemplateStore
public TemplateStore(IPreferenceStore store, String key)
Creates a new template store.- Parameters:
store- the preference store in which to store custom templates underkeykey- the key intostorewhere to store custom templates
-
TemplateStore
public TemplateStore(ContextTypeRegistry registry, IPreferenceStore store, String key)
Creates a new template store with a context type registry. Only templates that specify a context type contained in the registry will be loaded by this store if the registry is notnull.- Parameters:
registry- a context type registry, ornullif all templates should be loadedstore- the preference store in which to store custom templates underkeykey- the key intostorewhere to store custom templates
-
-
Method Detail
-
load
public void load() throws IOExceptionLoads the templates from contributions and preferences.- Overrides:
loadin classorg.eclipse.text.templates.TemplateStoreCore- Throws:
IOException- if loading fails.
-
startListeningForPreferenceChanges
public final void startListeningForPreferenceChanges()
Starts listening for property changes on the preference store. If the configured preference key changes, the template store isreloaded. CallstopListeningForPreferenceChanges()to remove any listener and stop the auto-updating behavior.- Overrides:
startListeningForPreferenceChangesin classorg.eclipse.text.templates.TemplateStoreCore- Since:
- 3.2
-
stopListeningForPreferenceChanges
public final void stopListeningForPreferenceChanges()
Stops the auto-updating behavior started by callingstartListeningForPreferenceChanges().- Overrides:
stopListeningForPreferenceChangesin classorg.eclipse.text.templates.TemplateStoreCore- Since:
- 3.2
-
save
public void save() throws IOExceptionSaves the templates to the preferences.- Overrides:
savein classorg.eclipse.text.templates.TemplateStoreCore- Throws:
IOException- if the templates cannot be written
-
restoreDefaults
public void restoreDefaults(boolean doSave)
Deletes all user-added templates and reverts all contributed templates.- Overrides:
restoreDefaultsin classorg.eclipse.text.templates.TemplateStoreCore- Parameters:
doSave-trueif the store should be saved after restoring- Since:
- 3.5
-
getRegistry
protected final ContextTypeRegistry getRegistry()
Description copied from class:org.eclipse.text.templates.TemplateStoreCoreReturns the registry.- Overrides:
getRegistryin classorg.eclipse.text.templates.TemplateStoreCore- Returns:
- Returns the registry
-
add
public void add(TemplatePersistenceData data)
-
delete
public void delete(TemplatePersistenceData data)
-
getTemplateData
public TemplatePersistenceData[] getTemplateData(boolean includeDeleted)
Description copied from class:org.eclipse.text.templates.TemplateStoreCoreReturns all template data.- Overrides:
getTemplateDatain classorg.eclipse.text.templates.TemplateStoreCore- Parameters:
includeDeleted- whether to include deleted data- Returns:
- all template data, whether enabled or not
-
getTemplateData
public TemplatePersistenceData getTemplateData(String id)
Description copied from class:org.eclipse.text.templates.TemplateStoreCoreReturns the template data of the template with ididornullif no such template can be found.- Overrides:
getTemplateDatain classorg.eclipse.text.templates.TemplateStoreCore- Parameters:
id- the id of the template data- Returns:
- the template data of the template with id
idornull
-
internalAdd
protected void internalAdd(TemplatePersistenceData data)
-
-