use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project flux by eclipse.
the class StubUtility method setCodeTemplate.
/**
* Only to be used by tests
*
* @param templateId the template id
* @param pattern the new pattern
* @param project not used
*/
public static void setCodeTemplate(String templateId, String pattern, IJavaProject project) {
TemplateStore codeTemplateStore = JavaPlugin.getDefault().getCodeTemplateStore();
TemplatePersistenceData data = codeTemplateStore.getTemplateData(templateId);
Template orig = data.getTemplate();
Template copy = new Template(orig.getName(), orig.getDescription(), orig.getContextTypeId(), pattern, true);
data.setTemplate(copy);
}
use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project xtext-eclipse by eclipse.
the class XtextTemplateStore method loadContributedTemplates.
@Override
protected void loadContributedTemplates() throws IOException {
if (resource == null)
return;
TemplateReaderWriter reader = new TemplateReaderWriter();
InputStream openStream = null;
try {
openStream = resource.openStream();
try {
TemplatePersistenceData[] read = reader.read(openStream, null);
for (TemplatePersistenceData templatePersistenceData : read) {
internalAdd(templatePersistenceData);
}
} finally {
openStream.close();
}
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project dbeaver by serge-rider.
the class SQLTemplateStore method readContributedTemplates.
private Collection<TemplatePersistenceData> readContributedTemplates() throws IOException {
Collection<TemplatePersistenceData> templates = new ArrayList<>();
readIncludedTemplates(SQLEditorActivator.PLUGIN_ID, templates, "templates/default-templates.xml", "$nl$/templates/default-templates.properties");
// Read templates for DS providers
for (DBPDataSourceProviderDescriptor provider : DBWorkbench.getPlatform().getDataSourceProviderRegistry().getDataSourceProviders()) {
readIncludedTemplates(provider.getPluginId(), templates, "templates/" + provider.getId() + "-templates.xml", "$nl$/templates/" + provider.getId() + "-templates.properties");
}
return templates;
}
use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project dbeaver by serge-rider.
the class SQLTemplateStore method readIncludedTemplates.
private void readIncludedTemplates(String contributorId, Collection<TemplatePersistenceData> templates, String file, String translations) throws IOException {
if (file != null) {
Bundle plugin = Platform.getBundle(contributorId);
URL url = FileLocator.find(plugin, Path.fromOSString(file), null);
if (url != null) {
ResourceBundle bundle = null;
if (translations != null) {
URL bundleURL = FileLocator.find(plugin, Path.fromOSString(translations), null);
if (bundleURL != null) {
InputStream bundleStream = bundleURL.openStream();
try {
bundle = new PropertyResourceBundle(bundleStream);
} finally {
ContentUtils.close(bundleStream);
}
}
}
InputStream stream = new BufferedInputStream(url.openStream());
try {
TemplateReaderWriter reader = new TemplateReaderWriter();
TemplatePersistenceData[] datas = reader.read(stream, bundle);
for (TemplatePersistenceData data : datas) {
if (data.isCustom()) {
if (data.getId() == null)
log.error("No template id specified");
else
log.error("Template " + data.getTemplate().getName() + " deleted");
} else if (validateTemplate(data.getTemplate())) {
templates.add(data);
}
}
} finally {
ContentUtils.close(stream);
}
}
}
}
use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project dbeaver by dbeaver.
the class SQLTemplateStore method readContributedTemplates.
private Collection<TemplatePersistenceData> readContributedTemplates() throws IOException {
Collection<TemplatePersistenceData> templates = new ArrayList<>();
readIncludedTemplates(SQLEditorActivator.PLUGIN_ID, templates, "templates/default-templates.xml", "$nl$/templates/default-templates.properties");
// Read templates for DS providers
for (DBPDataSourceProviderDescriptor provider : DBWorkbench.getPlatform().getDataSourceProviderRegistry().getDataSourceProviders()) {
readIncludedTemplates(provider.getPluginId(), templates, "templates/" + provider.getId() + "-templates.xml", "$nl$/templates/" + provider.getId() + "-templates.properties");
}
return templates;
}
Aggregations