protected JsonContentAssistProcessor createContentAssistProcessor(ContentAssistant ca) { return new JsonContentAssistProcessor(ca, null){ @Override protected TemplateStore getTemplateStore() { return null; } @Override protected ContextTypeRegistry getContextTypeRegistry() { return null; } @Override protected String getContextTypeId(Model model, String path) { return null; }}; }
/** * Removes any duplicates from a template store. Duplicate user added templates * are copied over their contributed siblings. If isCodeTemplates is true, * any user added templates are then removed. * * @param store * @param isCodeTemplates */ public static void pruneDuplicates(TemplateStore store, boolean isCodeTemplates) { TemplatePersistenceData[] datas= store.getTemplateData(true); for (int i= datas.length - 1; i >= 0; i--) { TemplatePersistenceData data= datas[i]; if (data.isUserAdded()) { // find a contributed template that is similar and check it TemplatePersistenceData similar= findSimilarTemplate(datas, data.getTemplate(), isCodeTemplates); if (similar != data && !similar.isUserAdded()) { similar.setTemplate(data.getTemplate()); store.delete(data); } } } if (isCodeTemplates) { datas= store.getTemplateData(true); for (int i= datas.length - 1; i >= 0; i--) { if (datas[i].isUserAdded()) store.delete(datas[i]); } } }
/** * Returns this plug-in's template store. * * @return the template store of this plug-in instance */ public TemplateStore getTemplateStore() { if (mTemplateStore == null) { mTemplateStore= new ContributionTemplateStore(getContextTypeRegistry(), NSISPreferences.getInstance().getPreferenceStore(), INSISEditorPreferenceConstants.CUSTOM_TEMPLATES); try { mTemplateStore.load(); } catch (IOException e) { log(e); } } return mTemplateStore; }
/** * Performs the SilverStripe version specific tasks when creating new project layout project * @param project Destination project * @param monitor Monitor to update when creating the layout * @param templateRegistry Template registry to look through * @param isFrameworkLayout If the project is a framework only project this is set to true * @throws CoreException */ public void createProjectLayout(Wizard wizard, IProject project, IProgressMonitor monitor, ContextTypeRegistry templateRegistry, TemplateStore templateStore, boolean isFrameworkLayout) throws CoreException { //Generate the Page.php file if(isFrameworkLayout==false) { Template pageTemplateToCompile=templateStore.findTemplateById("ca.edchipman.silverstripepdt.SilverStripe.templates.newssproject.ss30.defaultpage"); PHPTemplateStore.CompiledTemplate pageTemplate=PHPTemplateStore.compileTemplate(templateRegistry, pageTemplateToCompile, project.getName()+"/code", "Page.php"); new SilverStripeFileCreator().createFile(wizard, project.getName()+"/code", "Page.php", monitor, pageTemplate.string, pageTemplate.offset); } //Generate the _config.php file Template configTemplateToCompile; if(isFrameworkLayout) { configTemplateToCompile=templateStore.findTemplateById("ca.edchipman.silverstripepdt.SilverStripe.templates.newssproject.ss30.framework.config"); }else { configTemplateToCompile=templateStore.findTemplateById("ca.edchipman.silverstripepdt.SilverStripe.templates.newssproject.ss30.config"); } PHPTemplateStore.CompiledTemplate configTemplate=PHPTemplateStore.compileTemplate(templateRegistry, configTemplateToCompile, project.getName(), "_config.php"); new SilverStripeFileCreator().createFile(wizard, project.getName(), "_config.php", monitor, configTemplate.string, configTemplate.offset, true); }
@SuppressWarnings("deprecation") @Override protected Template[] getTemplates(String contextTypeId) { if (contextType.getId().equals(contextTypeId)) { Template[] computedTemplates = null; if (templates != null) { computedTemplates = templates.getTemplate().toArray(new Template[templates.getTemplate().size()]); } TemplateStore templateStore = CustomTemplateAccess.getInstance().getTemplateStore(); if (templateStore != null) { Template[] customTemplates = templateStore.getTemplates(contextTypeId); if (customTemplates != null && customTemplates.length > 0) { if (computedTemplates == null) { computedTemplates = customTemplates; } else { List<Template> allTempaltes = new ArrayList<Template>( computedTemplates.length + customTemplates.length); allTempaltes.addAll(Arrays.asList(computedTemplates)); allTempaltes.addAll(Arrays.asList(customTemplates)); computedTemplates = allTempaltes.toArray(new Template[allTempaltes.size()]); } } } if (computedTemplates != null) { for (Template template : computedTemplates) { String pattern = template.getPattern(); pattern = pattern.replace("\r\n", "\n"); pattern = pattern.replace("\n", Strings.EOL); template.setPattern(pattern); } return computedTemplates; } } return NO_TEMPLATES; }
public KaizenTemplatePreferences(SourceViewerConfiguration sourceViewerConfiguration, IPreferenceStore preferenceStore, TemplateStore templateStore, ContextTypeRegistry contextTypeRegistry) { this.sourceViewerConfiguration = sourceViewerConfiguration; setPreferenceStore(preferenceStore); setTemplateStore(templateStore); setContextTypeRegistry(contextTypeRegistry); }
/** * Only to be used by tests * * @param templateId the template id * @param pattern the new pattern * @param project not used */ public static void setCodeTemplate(String templateId, String pattern, IJavaProject project) { TemplateStore codeTemplateStore= JavaPlugin.getDefault().getCodeTemplateStore(); TemplatePersistenceData data= codeTemplateStore.getTemplateData(templateId); Template orig= data.getTemplate(); Template copy= new Template(orig.getName(), orig.getDescription(), orig.getContextTypeId(), pattern, true); data.setTemplate(copy); }
protected void warnAboutTypeCommentDeprecation() { String key= IUIConstants.DIALOGSTORE_TYPECOMMENT_DEPRECATED; if (OptionalMessageDialog.isDialogEnabled(key)) { TemplateStore templates= JavaPlugin.getDefault().getTemplateStore(); boolean isOldWorkspace= templates.findTemplate("filecomment") != null && templates.findTemplate("typecomment") != null; //$NON-NLS-1$ //$NON-NLS-2$ if (!isOldWorkspace) { OptionalMessageDialog.setDialogEnabled(key, false); } String title= NewWizardMessages.NewElementWizard_typecomment_deprecated_title; String message= NewWizardMessages.NewElementWizard_typecomment_deprecated_message; OptionalMessageDialog.open(key, getShell(), title, null, message, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); } }
public ApexClassTemplateSelectionPage(final ComponentModel componentModel, final TemplateStore templateStore) { super( componentModel, ApexClassTemplateContextType.ID, templateStore, ApexClassTemplateSelectionPage.class.getSimpleName(), NewWizardMessages.ClassTemplate_desc ); }
public ApexTriggerTemplateSelectionPage(final ComponentModel componentModel, final TemplateStore templateStore) { super( componentModel, ApexTriggerTemplateContextType.ID, templateStore, ApexTriggerTemplateSelectionPage.class.getSimpleName(), NewWizardMessages.TriggerTemplate_desc ); }
public ApexComponentTemplateSelectionPage(final TemplateStore templateStore) { super( ApexComponentTemplateContextType.ID, templateStore, ApexComponentTemplateSelectionPage.class.getSimpleName(), NewWizardMessages.ComponentTemplate_desc ); }
public ApexPageTemplateSelectionPage(final TemplateStore templateStore) { super( ApexPageTemplateContextType.ID, templateStore, ApexPageTemplateSelectionPage.class.getSimpleName(), NewWizardMessages.PageTemplate_desc ); }
/** * Creates a new wizard page with the given name, title, and image. * * @param contextTypeId where the templates are registered in the template store * @param templateStore the source of the templates * @param pageName the name of the page * @param description the description text for this dialog page, or <code>null</code> if none */ protected AbstractTemplateSelectionPage( final String contextTypeId, final TemplateStore templateStore, final String pageName, final String description ) { super(pageName, NewWizardMessages.WizardPage_0, null); setDescription(description); this.contextTypeId = contextTypeId; this.templateStore = templateStore; }
/** * Performs the SilverStripe version specific tasks when creating new project layout project * @param project Destination project * @param monitor Monitor to update when creating the layout * @param templateRegistry Template registry to look through * @param isFrameworkLayout If the project is a framework only project this is set to true * @throws CoreException */ public void createProjectLayout(Wizard wizard, IProject project, IProgressMonitor monitor, ContextTypeRegistry templateRegistry, TemplateStore templateStore, boolean isFrameworkLayout) throws CoreException { //Generate the Page.php file Template pageTemplateToCompile=templateStore.findTemplateById("ca.edchipman.silverstripepdt.SilverStripe.templates.newssproject.defaultpage"); PHPTemplateStore.CompiledTemplate pageTemplate=PHPTemplateStore.compileTemplate(templateRegistry, pageTemplateToCompile, project.getName()+"/code", "Page.php"); new SilverStripeFileCreator().createFile(wizard, project.getName()+"/code", "Page.php", monitor, pageTemplate.string, pageTemplate.offset); //Generate the _config.php file Template configTemplateToCompile=templateStore.findTemplateById("ca.edchipman.silverstripepdt.SilverStripe.templates.newssproject.config"); PHPTemplateStore.CompiledTemplate configTemplate=PHPTemplateStore.compileTemplate(templateRegistry, configTemplateToCompile, project.getName(), "_config.php"); new SilverStripeFileCreator().createFile(wizard, project.getName(), "_config.php", monitor, configTemplate.string, configTemplate.offset, true); }
/** * Performs the SilverStripe version specific tasks when creating new project layout project * @param project Destination project * @param monitor Monitor to update when creating the layout * @param templateRegistry Template registry to look through * @param isFrameworkLayout If the project is a framework only project this is set to true * @throws CoreException */ public void createProjectLayout(Wizard wizard, IProject project, IProgressMonitor monitor, ContextTypeRegistry templateRegistry, TemplateStore templateStore, boolean isFrameworkLayout) throws CoreException { //Generate the Page.php file Template pageTemplateToCompile=templateStore.findTemplateById("ca.edchipman.silverstripepdt.SilverStripe.templates.newssproject.defaultpage"); PHPTemplateStore.CompiledTemplate pageTemplate=PHPTemplateStore.compileTemplate(templateRegistry, pageTemplateToCompile, project.getName()+"/code", "Page.php"); new SilverStripeFileCreator().createFile(wizard, project.getName()+"/code", "Page.php", monitor, pageTemplate.string, pageTemplate.offset); //Generate the _config.php file Template configTemplateToCompile=templateStore.findTemplateById("ca.edchipman.silverstripepdt.SilverStripe.templates.newssproject.ss23.config"); PHPTemplateStore.CompiledTemplate configTemplate=PHPTemplateStore.compileTemplate(templateRegistry, configTemplateToCompile, project.getName(), "_config.php"); new SilverStripeFileCreator().createFile(wizard, project.getName(), "_config.php", monitor, configTemplate.string, configTemplate.offset, true); }
/** * Performs the SilverStripe version specific tasks when creating new project layout project * @param project Destination project * @param monitor Monitor to update when creating the layout * @param templateRegistry Template registry to look through * @param isFrameworkLayout If the project is a framework only project this is set to true * @throws CoreException */ public void createProjectLayout(Wizard wizard, IProject project, IProgressMonitor monitor, ContextTypeRegistry templateRegistry, TemplateStore templateStore, boolean isFrameworkLayout) throws CoreException { //Generate the Page.php file if(isFrameworkLayout==false) { Template pageTemplateToCompile=templateStore.findTemplateById("ca.edchipman.silverstripepdt.SilverStripe.templates.newssproject.ss31.defaultpage"); PHPTemplateStore.CompiledTemplate pageTemplate=PHPTemplateStore.compileTemplate(templateRegistry, pageTemplateToCompile, project.getName()+"/code", "Page.php"); new SilverStripeFileCreator().createFile(wizard, project.getName()+"/code", "Page.php", monitor, pageTemplate.string, pageTemplate.offset); } //Create the config folder IPath ymlConfigPath = new Path("_config"); if (ymlConfigPath.segmentCount() > 0) { IFolder folder=project.getFolder(ymlConfigPath); CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 10)); } else { monitor.worked(10); } //Create config.yml Template ymlConfigTemplateToCompile=templateStore.findTemplateById("ca.edchipman.silverstripepdt.SilverStripe.templates.newssproject.ss31.ymlconfig"); PHPTemplateStore.CompiledTemplate ymlConfigTemplate=PHPTemplateStore.compileTemplate(templateRegistry, ymlConfigTemplateToCompile, project.getName()+"/_config", "config.yml"); new SilverStripeFileCreator().createFile(wizard, project.getName()+"/_config", "config.yml", monitor, ymlConfigTemplate.string, ymlConfigTemplate.offset, true); //Generate the _config.php file Template configTemplateToCompile=templateStore.findTemplateById("ca.edchipman.silverstripepdt.SilverStripe.templates.newssproject.ss31.config"); PHPTemplateStore.CompiledTemplate configTemplate=PHPTemplateStore.compileTemplate(templateRegistry, configTemplateToCompile, project.getName(), "_config.php"); new SilverStripeFileCreator().createFile(wizard, project.getName(), "_config.php", monitor, configTemplate.string, configTemplate.offset, true); }
/** * Returns the template store for the xml editor templates. * * @return the template store for the xml editor templates */ public TemplateStore getTemplateStore() { if (templateStore == null) { templateStore = new SilverStripeTemplateStore(getTemplateContextRegistry(), getPreferenceStore(), "ca.edchipman.silverstripepdt.SilverStripe.templates"); try { templateStore.load(); } catch (IOException e) { Logger.logException(e); } } return templateStore; }
/** * Returns the template store for the xml editor templates. * * @return the template store for the xml editor templates */ public TemplateStore getCATemplateStore() { if (caTemplateStore == null) { caTemplateStore = new SilverStripeTemplateStore(getCATemplateContextRegistry(), getPreferenceStore(), "ca.edchipman.silverstripepdt.contentassist.templates"); try { caTemplateStore.load(); } catch (IOException e) { Logger.logException(e); } } return caTemplateStore; }
protected Template[] getTemplates(String contextTypeId) { Template templates[] = null; TemplateStore store = getTemplateStore(); if (store != null) templates = store.getTemplates(contextTypeId); return templates; }
public TemplateStore getSSTemplateStore() { TemplateStore templateStore = new SilverStripeTemplateStore(getTemplatesContextTypeRegistry(), getPreferenceStore(), "ca.edchipman.silverstripepdt.SilverStripe.classtemplates"); try { templateStore.load(); } catch (IOException e) { Logger.logException(e); } return templateStore; }
@Inject public CheckTemplateProposalProvider(final TemplateStore templateStore, final ContextTypeRegistry registry, final ContextTypeIdHelper helper) { super(templateStore, registry, helper); }
@Inject public CheckCfgTemplateProposalProvider(final TemplateStore templateStore, final ContextTypeRegistry registry, final ContextTypeIdHelper helper) { super(templateStore, registry, helper); this.templateStore = templateStore; }
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { fStore= (TemplateStore) newInput; }
public Class<? extends TemplateStore> bindTemplateStore() { return XtextTemplateStore.class; }
@Inject public DefaultTemplateProposalProvider(TemplateStore templateStore, ContextTypeRegistry registry, ContextTypeIdHelper helper) { this.templateStore = templateStore; this.registry = registry; this.helper = helper; }
public TemplateStore getTemplateStoreInternal() { return templateStoreInternal; }
public void setTemplateStoreInternal(TemplateStore templateStoreInternal) { this.templateStoreInternal = templateStoreInternal; setTemplateStore(templateStoreInternal); }
@Inject public XtextTemplatePreferencePage(IPreferenceStore preferenceStore, ContextTypeRegistry registry, TemplateStore templateStore) { setPreferenceStore(preferenceStore); setContextTypeRegistry(registry); setTemplateStore(templateStore); }
@Inject public SGenTemplateProposalProvider(TemplateStore templateStore, ContextTypeRegistry registry, ContextTypeIdHelper helper) { super(templateStore, registry, helper); this.helper = helper; }
@Override protected TemplateStore getTemplateStore() { return Activator.getDefault().getTemplateStore(); }
public TemplateStore getTemplateStore() { return this.templateStore; }