public class TemplateStore extends Object
org.eclipse.ui.editors.templates
extension point, use a ContributionTemplateStore.| Constructor and Description |
|---|
TemplateStore(ContextTypeRegistry registry,
IPreferenceStore store,
String key)
Creates a new template store with a context type registry.
|
TemplateStore(IPreferenceStore store,
String key)
Creates a new template store.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(TemplatePersistenceData data)
Adds a template encapsulated in its persistent form.
|
void |
delete(TemplatePersistenceData data)
Removes a template from the store.
|
Template |
findTemplate(String name)
Returns the first enabled template that matches the name.
|
Template |
findTemplate(String name,
String contextTypeId)
Returns the first enabled template that matches both name and context type id.
|
Template |
findTemplateById(String id)
Returns the first enabled template that matches the given template id.
|
protected ContextTypeRegistry |
getRegistry()
Returns the registry.
|
TemplatePersistenceData[] |
getTemplateData(boolean includeDeleted)
Returns all template data.
|
TemplatePersistenceData |
getTemplateData(String id)
Returns the template data of the template with id
id or
null if no such template can be found. |
Template[] |
getTemplates()
Returns all enabled templates.
|
Template[] |
getTemplates(String contextTypeId)
Returns all enabled templates for the given context type.
|
protected void |
handleException(IOException x)
Handles an
IOException thrown during reloading the preferences due to a preference
store update. |
protected void |
internalAdd(TemplatePersistenceData data)
Adds a template to the internal store.
|
void |
load()
Loads the templates from contributions and preferences.
|
protected void |
loadContributedTemplates()
Hook method to load contributed templates.
|
void |
restoreDefaults()
Deletes all user-added templates and reverts all contributed templates.
|
void |
restoreDeleted()
Restores all contributed templates that have been deleted.
|
void |
save()
Saves the templates to the preferences.
|
void |
startListeningForPreferenceChanges()
Starts listening for property changes on the preference store.
|
void |
stopListeningForPreferenceChanges()
Stops the auto-updating behavior started by calling
startListeningForPreferenceChanges(). |
public TemplateStore(IPreferenceStore store, String key)
store - the preference store in which to store custom templates
under keykey - the key into store where to store custom
templatespublic TemplateStore(ContextTypeRegistry registry, IPreferenceStore store, String key)
null.registry - a context type registry, or null if all
templates should be loadedstore - the preference store in which to store custom templates
under keykey - the key into store where to store custom
templatespublic void load()
throws IOException
IOException - if loading fails.public final void startListeningForPreferenceChanges()
reloaded. Call
stopListeningForPreferenceChanges() to remove any listener and stop the
auto-updating behavior.public final void stopListeningForPreferenceChanges()
startListeningForPreferenceChanges().protected void handleException(IOException x)
IOException thrown during reloading the preferences due to a preference
store update. The default is to write to stderr.x - the exceptionprotected void loadContributedTemplates()
throws IOException
The default implementation does nothing.
IOException - if loading failsprotected void internalAdd(TemplatePersistenceData data)
data - the template data to addpublic void save()
throws IOException
IOException - if the templates cannot be writtenpublic void add(TemplatePersistenceData data)
data - the template to addpublic void delete(TemplatePersistenceData data)
data - the template to removepublic void restoreDeleted()
public void restoreDefaults()
public Template[] getTemplates()
public Template[] getTemplates(String contextTypeId)
contextTypeId - the id of the context type of the requested templates, or null if all templates should be returnedpublic Template findTemplate(String name)
name - the name of the template searched fornull if none is foundpublic Template findTemplate(String name, String contextTypeId)
name - the name of the template searched forcontextTypeId - the context type id to clip unwanted templates, or null if any context type is OKnull if none is foundpublic Template findTemplateById(String id)
id - the id of the template searched fornull if none is foundpublic TemplatePersistenceData[] getTemplateData(boolean includeDeleted)
includeDeleted - whether to include deleted datapublic TemplatePersistenceData getTemplateData(String id)
id or
null if no such template can be found.id - the id of the template dataid or nullprotected final ContextTypeRegistry getRegistry()
Guidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.