public void add(org.eclipse.jface.text.templates.persistence.TemplatePersistenceData data) { super.add(data); }
public TemplatePersistenceData[] getTemplateData() { if (fProjectStore != null) { return fProjectStore.getTemplateData(true); } else { return fInstanceStore.getTemplateData(true); } }
@Override public void preferenceChange(PreferenceChangeEvent event) { /* * Don't load if we are in the process of saving ourselves. We are in sync anyway after the * save operation, and clients may trigger reloading by listening to preference store * updates. */ if (!fIgnorePreferenceStoreChanges && fKey.equals(event.getKey())) try { load(); } catch (IOException x) { handleException(x); } } };
public void load() throws IOException { if (fProjectStore != null) { fProjectStore.load(); Set<String> datas= new HashSet<>(); TemplatePersistenceData[] data= fProjectStore.getTemplateData(false); for (int i= 0; i < data.length; i++) { datas.add(data[i].getId()); } data= fInstanceStore.getTemplateData(false); for (int i= 0; i < data.length; i++) { TemplatePersistenceData orig= data[i]; if (!datas.contains(orig.getId())) { TemplatePersistenceData copy= new TemplatePersistenceData(new Template(orig.getTemplate()), orig.isEnabled(), orig.getId()); fProjectStore.add(copy); copy.setDeleted(true); } } } }
public void revertChanges() throws IOException { if (fProjectStore != null) { // nothing to do } else { fInstanceStore.load(); } } }
registry.addContextType(new CodeTemplateContextType(CodeTemplatePreferences.INTERFACESNIPPET_CONTEXTTYPE)); TemplateStoreCore tscore = new TemplateStoreCore(defEclipsePrefs, CUSTOM_CODE_TEMPLATES); try { tscore.load(); } catch (IOException e) {
/** * Deletes all user-added templates and reverts all contributed templates. * <p> * <strong>Note:</strong> the store will be saved after restoring. * </p> */ public void restoreDefaults() { restoreDefaults(true); }
public Template findTemplateById(String id) { Template template= null; if (fProjectStore != null) template= fProjectStore.findTemplateById(id); if (template == null) template= fInstanceStore.findTemplateById(id); return template; }
/** * Returns the first enabled template that matches the name. * * @param name the name of the template searched for * @return the first enabled template that matches both name and context type id, or <code>null</code> if none is found */ public Template findTemplate(String name) { return findTemplate(name, null); }
public void delete(org.eclipse.jface.text.templates.persistence.TemplatePersistenceData data) { super.delete(data); }
/** * Validates a template against the context type registered in the context * type registry. Returns always <code>true</code> if no registry is * present. * * @param template the template to validate * @return <code>true</code> if validation is successful or no context * type registry is specified, <code>false</code> if validation * fails */ private boolean validateTemplate(Template template) { String contextTypeId= template.getContextTypeId(); if (contextExists(contextTypeId)) { if (fRegistry != null) try { fRegistry.getContextType(contextTypeId).validate(template.getPattern()); } catch (TemplateException e) { return false; } return true; } return false; }
public void restoreDefaults() { if (fProjectStore == null) { fInstanceStore.restoreDefaults(false); } else { try { load(); } catch (IOException e) { JavaManipulationPlugin.log(e); } } }
public boolean isProjectSpecific(String id) { if (id == null) { return false; } if (fProjectStore == null) return false; return fProjectStore.findTemplateById(id) != null; }
@Override public org.eclipse.jface.text.templates.persistence.TemplatePersistenceData getTemplateData(String id) { TemplatePersistenceData data= super.getTemplateData(id); org.eclipse.jface.text.templates.persistence.TemplatePersistenceData wrap= new org.eclipse.jface.text.templates.persistence.TemplatePersistenceData(data); return wrap; }
load(); } catch (IOException x) { handleException(x);
private void loadCustomTemplates() throws IOException { String pref= fPreferenceStore.get(fKey, null); if (pref != null && pref.trim().length() > 0) { Reader input= new StringReader(pref); TemplateReaderWriter reader= new TemplateReaderWriter(); TemplatePersistenceData[] datas= reader.read(input); for (TemplatePersistenceData data : datas) { add(data); } } }
public static Template getCodeTemplate(String id, IJavaProject project) { if (project == null) return JavaManipulation.getCodeTemplateStore().findTemplateById(id); ProjectTemplateStore projectStore= new ProjectTemplateStore(project.getProject()); try { projectStore.load(); } catch (IOException e) { JavaManipulationPlugin.log(e); } return projectStore.findTemplateById(id); }
public void setProjectSpecific(String id, boolean projectSpecific) { Assert.isNotNull(fProjectStore); TemplatePersistenceData data= fProjectStore.getTemplateData(id); if (data == null) { return; // does not exist } else { data.setDeleted(!projectSpecific); } }
@Override public org.eclipse.jface.text.templates.persistence.TemplatePersistenceData[] getTemplateData(boolean includeDeleted) { TemplatePersistenceData[] list= super.getTemplateData(includeDeleted); org.eclipse.jface.text.templates.persistence.TemplatePersistenceData[] wraps= new org.eclipse.jface.text.templates.persistence.TemplatePersistenceData[list.length]; for (int i= 0; i < wraps.length; i++) { wraps[i]= new org.eclipse.jface.text.templates.persistence.TemplatePersistenceData(list[i]); } return wraps; }
/** * Returns the first enabled template that matches the given template id. * * @param id the id of the template searched for * @return the first enabled template that matches id, or <code>null</code> if none is found * @since 3.1 */ public Template findTemplateById(String id) { TemplatePersistenceData data= getTemplateData(id); if (data != null && !data.isDeleted()) return data.getTemplate(); return null; }