Class TemplateStore
java.lang.Object
org.eclipse.text.templates.TemplateStoreCore
org.eclipse.jface.text.templates.persistence.TemplateStore
- Direct Known Subclasses:
ContributionTemplateStore
A collection of templates. Clients may instantiate this class. In order to
load templates contributed using the
org.eclipse.ui.editors.templates
extension point, use a ContributionTemplateStore.- Since:
- 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionTemplateStore(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
Modifier and TypeMethodDescriptionvoidadd(TemplatePersistenceData data) voidprotected final ContextTypeRegistryReturns the registry.getTemplateData(boolean includeDeleted) Returns all template data.Returns the template data of the template with ididornullif no such template can be found.protected voidvoidload()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.final voidStarts listening for property changes on the preference store.final voidStops the auto-updating behavior started by callingstartListeningForPreferenceChanges().Methods inherited from class org.eclipse.text.templates.TemplateStoreCore
add, delete, findTemplate, findTemplate, findTemplateById, getKey, getTemplates, getTemplates, handleException, internalAdd, internalGetTemplates, loadContributedTemplates, restoreDefaults, restoreDeleted
-
Constructor Details
-
TemplateStore
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
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 Details
-
load
Loads the templates from contributions and preferences.- Overrides:
loadin classTemplateStoreCore- 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 classTemplateStoreCore- Since:
- 3.2
-
stopListeningForPreferenceChanges
public final void stopListeningForPreferenceChanges()Stops the auto-updating behavior started by callingstartListeningForPreferenceChanges().- Overrides:
stopListeningForPreferenceChangesin classTemplateStoreCore- Since:
- 3.2
-
save
Saves the templates to the preferences.- Overrides:
savein classTemplateStoreCore- 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 classTemplateStoreCore- Parameters:
doSave-trueif the store should be saved after restoring- Since:
- 3.5
-
getRegistry
Description copied from class:TemplateStoreCoreReturns the registry.- Overrides:
getRegistryin classTemplateStoreCore- Returns:
- Returns the registry
-
add
-
delete
-
getTemplateData
Description copied from class:TemplateStoreCoreReturns all template data.- Overrides:
getTemplateDatain classTemplateStoreCore- Parameters:
includeDeleted- whether to include deleted data- Returns:
- all template data, whether enabled or not
-
getTemplateData
Description copied from class:TemplateStoreCoreReturns the template data of the template with ididornullif no such template can be found.- Overrides:
getTemplateDatain classTemplateStoreCore- Parameters:
id- the id of the template data- Returns:
- the template data of the template with id
idornull
-
internalAdd
-