comparison dwtx/jface/text/templates/persistence/TemplateStore.d @ 136:6dcb0baaa031

Regex removal of throws decls, some instanceof
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 02:20:40 +0200
parents 65801ad2b265
children b6bad70d540a
comparison
equal deleted inserted replaced
135:65801ad2b265 136:6dcb0baaa031
108 /** 108 /**
109 * Loads the templates from contributions and preferences. 109 * Loads the templates from contributions and preferences.
110 * 110 *
111 * @throws IOException if loading fails. 111 * @throws IOException if loading fails.
112 */ 112 */
113 public void load() throws IOException { 113 public void load() {
114 fTemplates.clear(); 114 fTemplates.clear();
115 loadContributedTemplates(); 115 loadContributedTemplates();
116 loadCustomTemplates(); 116 loadCustomTemplates();
117 } 117 }
118 118
176 * <p> 176 * <p>
177 * The default implementation does nothing.</p> 177 * The default implementation does nothing.</p>
178 * 178 *
179 * @throws IOException if loading fails 179 * @throws IOException if loading fails
180 */ 180 */
181 protected void loadContributedTemplates() throws IOException { 181 protected void loadContributedTemplates() {
182 } 182 }
183 183
184 /** 184 /**
185 * Adds a template to the internal store. The added templates must have 185 * Adds a template to the internal store. The added templates must have
186 * a unique id. 186 * a unique id.
203 /** 203 /**
204 * Saves the templates to the preferences. 204 * Saves the templates to the preferences.
205 * 205 *
206 * @throws IOException if the templates cannot be written 206 * @throws IOException if the templates cannot be written
207 */ 207 */
208 public void save() throws IOException { 208 public void save() {
209 ArrayList custom= new ArrayList(); 209 ArrayList custom= new ArrayList();
210 for (Iterator it= fTemplates.iterator(); it.hasNext();) { 210 for (Iterator it= fTemplates.iterator(); it.hasNext();) {
211 TemplatePersistenceData data= cast(TemplatePersistenceData) it.next(); 211 TemplatePersistenceData data= cast(TemplatePersistenceData) it.next();
212 if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates 212 if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates
213 custom.add(data); 213 custom.add(data);
406 } 406 }
407 407
408 return null; 408 return null;
409 } 409 }
410 410
411 private void loadCustomTemplates() throws IOException { 411 private void loadCustomTemplates() {
412 String pref= fPreferenceStore.getString(fKey); 412 String pref= fPreferenceStore.getString(fKey);
413 if (pref !is null && pref.trim().length() > 0) { 413 if (pref !is null && pref.trim().length() > 0) {
414 Reader input= new StringReader(pref); 414 Reader input= new StringReader(pref);
415 TemplateReaderWriter reader= new TemplateReaderWriter(); 415 TemplateReaderWriter reader= new TemplateReaderWriter();
416 TemplatePersistenceData[] datas= reader.read(input); 416 TemplatePersistenceData[] datas= reader.read(input);