use of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData in project dbeaver by dbeaver.
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);
}
}
}
}
Aggregations