1 11 package org.eclipse.jdt.internal.corext.template.java; 12 13 import java.io.File ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IPath; 17 18 import org.eclipse.jdt.internal.ui.JavaPlugin; 19 20 25 public class Templates extends org.eclipse.jdt.internal.corext.template.java.TemplateSet { 26 27 private static final String TEMPLATE_FILE= "templates.xml"; 29 30 private static Templates fgTemplates; 31 32 39 public static Templates getInstance() { 40 if (fgTemplates == null) 41 fgTemplates= new Templates(); 42 43 return fgTemplates; 44 } 45 46 public Templates() { 47 super("template", JavaPlugin.getDefault().getTemplateContextRegistry()); create(); 49 } 50 51 52 private void create() { 53 54 try { 55 File templateFile= getTemplateFile(); 56 if (templateFile.exists()) { 57 addFromFile(templateFile, false); 58 } 59 60 } catch (CoreException e) { 61 JavaPlugin.log(e); 62 clear(); 63 } 64 65 } 66 67 72 public void reset() throws CoreException { 73 } 74 75 80 public void restoreDefaults() throws CoreException { 81 } 82 83 88 public void save() throws CoreException { 89 } 90 91 private static File getTemplateFile() { 92 IPath path= JavaPlugin.getDefault().getStateLocation(); 93 path= path.append(TEMPLATE_FILE); 94 95 return path.toFile(); 96 } 97 } 98 99 | Popular Tags |