1 11 package org.eclipse.ant.internal.ui.editor.templates; 12 13 import java.io.IOException ; 14 15 import org.eclipse.ant.internal.ui.AntUIPlugin; 16 import org.eclipse.jface.text.templates.ContextTypeRegistry; 17 import org.eclipse.jface.text.templates.persistence.TemplateStore; 18 import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry; 19 import org.eclipse.ui.editors.text.templates.ContributionTemplateStore; 20 21 22 public class AntTemplateAccess { 23 24 private static final String CUSTOM_TEMPLATES_KEY= "org.eclipse.ant.ui.customtemplates"; 26 27 private static AntTemplateAccess fgInstance; 28 29 30 private TemplateStore fStore; 31 32 33 private ContributionContextTypeRegistry fRegistry; 34 35 private AntTemplateAccess() { 36 } 37 38 43 public static AntTemplateAccess getDefault() { 44 if (fgInstance == null) { 45 fgInstance= new AntTemplateAccess(); 46 } 47 return fgInstance; 48 } 49 50 55 public TemplateStore getTemplateStore() { 56 if (fStore == null) { 57 fStore= new ContributionTemplateStore(getContextTypeRegistry(),AntUIPlugin.getDefault().getPreferenceStore(), CUSTOM_TEMPLATES_KEY); 58 try { 59 fStore.load(); 60 } catch (IOException e) { 61 AntUIPlugin.log(e); 62 } 63 } 64 return fStore; 65 } 66 67 72 public ContextTypeRegistry getContextTypeRegistry() { 73 if (fRegistry == null) { 74 fRegistry= new ContributionContextTypeRegistry(); 76 fRegistry.addContextType(BuildFileContextType.BUILDFILE_CONTEXT_TYPE); 77 fRegistry.addContextType(TargetContextType.TARGET_CONTEXT_TYPE); 78 fRegistry.addContextType(TaskContextType.TASK_CONTEXT_TYPE); 79 } 80 return fRegistry; 81 } 82 } 83 | Popular Tags |