org.eclipse.jface.text.templates.persistence.TemplateReaderWriter Java Examples
The following examples show how to use
org.eclipse.jface.text.templates.persistence.TemplateReaderWriter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XtextTemplateStore.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override protected void loadContributedTemplates() throws IOException { if (res==null) return; TemplateReaderWriter reader = new TemplateReaderWriter(); InputStream openStream = null; try { openStream = res.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); } }
Example #2
Source File: ConfigurableTemplateStore.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Contribute templates defined in file with the give URL. * * @param templates * the URL of the file with templates */ private void addTemplatesFromFile(final URL templates) { if (templates != null) { TemplateReaderWriter reader = new TemplateReaderWriter(); try { InputStream openStream = templates.openStream(); try { TemplatePersistenceData[] datas = reader.read(openStream, null); int templateCounter = 0; for (TemplatePersistenceData data : datas) { if (data.getId() == null) { templateCounter++; TemplatePersistenceData dataWithGenId = new TemplatePersistenceData(data.getTemplate(), data.isEnabled(), templates.getPath() + "." //$NON-NLS-1$ + templateCounter); dataWithGenId.setDeleted(data.isDeleted()); internalAdd(dataWithGenId); } else { // if contributed template has an id internalAdd(data); } } } finally { openStream.close(); } } catch (IOException e) { LOG.error(e); } } }
Example #3
Source File: ProjectTemplateStore.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static boolean hasProjectSpecificTempates(IProject project) { String pref= new ProjectScope(project).getNode(JavaUI.ID_PLUGIN).get(KEY, null); if (pref != null && pref.trim().length() > 0) { Reader input= new StringReader(pref); TemplateReaderWriter reader= new TemplateReaderWriter(); TemplatePersistenceData[] datas; try { datas= reader.read(input); return datas.length > 0; } catch (IOException e) { // ignore } } return false; }