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; }}; }
public static void registerContextTypes(ContextTypeRegistry registry) { registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CATCHBLOCK_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.GETTERBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.SETTERBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.NEWTYPE_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CLASSBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.INTERFACEBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.ENUMBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.ANNOTATIONBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.FILECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.TYPECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.FIELDCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.OVERRIDECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.DELEGATECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.GETTERCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.SETTERCOMMENT_CONTEXTTYPE)); }
/** * Returns the template context type registry for the java plug-in. * * @return the template context type registry for the java plug-in * @since 3.0 */ public synchronized ContextTypeRegistry getTemplateContextRegistry() { if (fContextTypeRegistry == null) { ContributionContextTypeRegistry registry= new ContributionContextTypeRegistry(JavaUI.ID_CU_EDITOR); TemplateContextType all_contextType= registry.getContextType(JavaContextType.ID_ALL); ((AbstractJavaContextType) all_contextType).initializeContextTypeResolvers(); registerJavaContext(registry, JavaContextType.ID_MEMBERS, all_contextType); registerJavaContext(registry, JavaContextType.ID_STATEMENTS, all_contextType); registerJavaContext(registry, SWTContextType.ID_ALL, all_contextType); all_contextType= registry.getContextType(SWTContextType.ID_ALL); registerJavaContext(registry, SWTContextType.ID_MEMBERS, all_contextType); registerJavaContext(registry, SWTContextType.ID_STATEMENTS, all_contextType); fContextTypeRegistry= registry; } return fContextTypeRegistry; }
/** * 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("PMD.ConstructorCallsOverridableMethod") @Inject public ConfigurableTemplateStore(final ContextTypeRegistry registry, final IPreferenceStore store, @Named(Constants.LANGUAGE_NAME) final String key, final AbstractUIPlugin plugin) { super(registry, store, key + ".templates"); //$NON-NLS-1$ this.res = getTemplateFileURL(plugin); this.preferenceStore = store; this.key = key + ".sharedTemplates"; //$NON-NLS-1$ try { load(); } catch (IOException e) { LOG.error(e.getMessage(), e); } }
public ContextTypeRegistry getContextTypeRegistry() { if (registry == null) { if (FluentMkUI.getDefault() != null) { ContributionContextTypeRegistry contributionRegistry = new ContributionContextTypeRegistry(); contributionRegistry.addContextType(SourceTemplateContextType.ID); registry = contributionRegistry; } else { ContextTypeRegistry contextTypeRegistry = new ContextTypeRegistry(); contextTypeRegistry.addContextType(new SourceTemplateContextType()); registry = contextTypeRegistry; } } return registry; }
public FluentMkTemplateCompletionProcessor(ITextEditor editor, String partition) { ContextTypeRegistry contextTypeRegistry = CustomTemplateAccess.getInstance().getContextTypeRegistry(); contextType = (SourceTemplateContextType) contextTypeRegistry.getContextType(SourceTemplateContextType.ID); if (contextType == null) { throw new IllegalStateException(); } }
/** * Returns the template context type registry for the java plug-in. * * @return the template context type registry for the java plug-in * */ public ContextTypeRegistry getTemplateContextRegistry() { if (fContextTypeRegistry == null) { ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry(CONTEXT_TYPE_REGISTRY_ID); fContextTypeRegistry = registry; } return fContextTypeRegistry; }
@Inject public XtextTemplateStore(ContextTypeRegistry registry, IPreferenceStore store, @Named(Constants.LANGUAGE_NAME) String key, AbstractUIPlugin plugin) { super(registry, store, key + ".templates"); res = getTemplateFileURL(plugin); try { load(); } catch (IOException e) { log.error(e.getMessage(), e); } }
public KaizenTemplatePreferences(SourceViewerConfiguration sourceViewerConfiguration, IPreferenceStore preferenceStore, TemplateStore templateStore, ContextTypeRegistry contextTypeRegistry) { this.sourceViewerConfiguration = sourceViewerConfiguration; setPreferenceStore(preferenceStore); setTemplateStore(templateStore); setContextTypeRegistry(contextTypeRegistry); }
@Override protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) { Model model = null; if (viewer.getDocument() instanceof JsonDocument) { model = ((JsonDocument)viewer.getDocument()).getModel(); } String contextType = getContextTypeId(model, currentPath.toString()); ContextTypeRegistry registry = getContextTypeRegistry(); if (registry != null) { return registry.getContextType(contextType); } else { return null; } }
/** * This method adds the given {@link TemplateVariableResolver} to each registered * {@link TemplateContextType}. * * @param javaPlugin is the {@link JavaPlugin}. * @param resolver is the {@link TemplateVariableResolver} to add. */ @SuppressWarnings({ "rawtypes" }) private void addResolver(JavaPlugin javaPlugin, TemplateVariableResolver resolver) { Assert.isNotNull(javaPlugin); Assert.isNotNull(resolver); ContextTypeRegistry codeTemplateContextRegistry = javaPlugin.getCodeTemplateContextRegistry(); Assert.isNotNull(codeTemplateContextRegistry); Iterator ctIter = codeTemplateContextRegistry.contextTypes(); while (ctIter.hasNext()) { TemplateContextType contextType = (TemplateContextType) ctIter.next(); contextType.addResolver(resolver); } }
/** * This method removes the given {@link TemplateVariableResolver} to each registered * {@link TemplateContextType}. * * @param javaPlugin is the {@link JavaPlugin}. * @param resolver is the {@link TemplateVariableResolver} to remove. */ @SuppressWarnings({ "rawtypes" }) private void removeResolver(JavaPlugin javaPlugin, TemplateVariableResolver resolver) { Assert.isNotNull(javaPlugin); Assert.isNotNull(resolver); ContextTypeRegistry codeTemplateContextRegistry = javaPlugin.getCodeTemplateContextRegistry(); Assert.isNotNull(codeTemplateContextRegistry); Iterator ctIter = codeTemplateContextRegistry.contextTypes(); while (ctIter.hasNext()) { TemplateContextType contextType = (TemplateContextType) ctIter.next(); contextType.removeResolver(resolver); } }
public SWTTemplateCompletionProposalComputer() { ContextTypeRegistry templateContextRegistry= JavaPlugin.getDefault().getTemplateContextRegistry(); fSWTTemplateEngine= createTemplateEngine(templateContextRegistry, SWTContextType.ID_ALL); fSWTMembersTemplateEngine= createTemplateEngine(templateContextRegistry, SWTContextType.ID_MEMBERS); fSWTStatementsTemplateEngine= createTemplateEngine(templateContextRegistry, SWTContextType.ID_STATEMENTS); JavaCore.addElementChangedListener(new BuildPathChangeListener()); }
public TemplateCompletionProposalComputer() { ContextTypeRegistry templateContextRegistry= JavaPlugin.getDefault().getTemplateContextRegistry(); fJavaTemplateEngine= createTemplateEngine(templateContextRegistry, JavaContextType.ID_ALL); fJavaMembersTemplateEngine= createTemplateEngine(templateContextRegistry, JavaContextType.ID_MEMBERS); fJavaStatementsTemplateEngine= createTemplateEngine(templateContextRegistry, JavaContextType.ID_STATEMENTS); fJavadocTemplateEngine= createTemplateEngine(templateContextRegistry, JavaDocContextType.ID); }
/** * Returns this plug-in's context type registry. * * @return the context type registry for this plug-in instance */ public ContextTypeRegistry getContextTypeRegistry() { if (mContextTypeRegistry == null) { mContextTypeRegistry= new ContributionContextTypeRegistry(); mContextTypeRegistry.addContextType(NSISTemplateContextType.NSIS_TEMPLATE_CONTEXT_TYPE); } return mContextTypeRegistry; }
public JFaceCompletionProposalComputer() { final ContextTypeRegistry templateContextRegistry = JavaPlugin.getDefault().getTemplateContextRegistry(); jFaceTemplateEngine = createTemplateEngine(templateContextRegistry, JFaceContextType.ID_ALL); jFaceMembersTemplateEngine = createTemplateEngine(templateContextRegistry, JFaceContextType.ID_MEMBERS); jFaceStatementsTemplateEngine = createTemplateEngine(templateContextRegistry, JFaceContextType.ID_STATEMENTS); JavaCore.addElementChangedListener(new BuildPathChangeListener()); }
/** * Returns the template context type registry for the html plugin. * * @return the template context type registry for the html plugin */ public ContextTypeRegistry getTemplateContextRegistry() { if (fContextTypeRegistry == null) { ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry(); registry.addContextType(CardContextType.CONTEXT_TYPE); fContextTypeRegistry = registry; } return fContextTypeRegistry; }
/** * 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 context type registry for creating SilverStripe classes. * @return the template context type registry for creating SilverStripe classes */ public ContextTypeRegistry getNewClassContextRegistry() { if (fClassContextTypeRegistry == null) { ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry(); registry.addContextType(new CodeTemplateContextType(NewSilverStripeClassWizardTemplatePage.NEW_CLASS_CONTEXTTYPE)); fClassContextTypeRegistry = registry; } return fClassContextTypeRegistry; }
/** * Returns the template context type registry for SilverStripe template files. * @return the template context type registry for SilverStripe template files */ public ContextTypeRegistry getTemplateContextRegistry() { if (fContextTypeRegistry == null) { ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry(); registry.addContextType(new CodeTemplateContextType(NewSilverStripeTemplatesWizardPage.NEW_SS_TEMPLATE_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(NewSilverStripeTemplatesWizardPage.NEW_SS_30_TEMPLATE_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(NewSilverStripeProjectWizard.NEW_SS_PROJECT_TEMPLATE_CONTEXTTYPE)); fContextTypeRegistry = registry; } return fContextTypeRegistry; }
/** * Returns the content assist template context type registry for the xml plugin. * * @return the content assist template context type registry for the xml plugin */ public ContextTypeRegistry getCATemplateContextRegistry() { if (caContextTypeRegistry == null) { ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry(); registry.addContextType(new CodeTemplateContextType(SSTemplateCompletionProcessor.TEMPLATE_CONTEXT_ID)); registry.addContextType(new CodeTemplateContextType(NewSilverStripeTemplatesWizardPage.NEW_SS_TEMPLATE_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(NewSilverStripeTemplatesWizardPage.NEW_SS_30_TEMPLATE_CONTEXTTYPE)); caContextTypeRegistry = registry; } return caContextTypeRegistry; }
protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) { TemplateContextType type = null; ContextTypeRegistry registry = getTemplateContextRegistry(); if (registry != null) type = registry.getContextType(fContextTypeId); return type; }
/** * {@inheritDoc} * @see IStartup#earlyStartup() */ public void earlyStartup() { // check if plug-in org.eclipse.jdt.ui is already active final Bundle bundle = Platform.getBundle(SilverStripePDTPlugin.PLUGIN_ID); if (bundle != null && bundle.getState() == Bundle.ACTIVE) { // register resolvers registerResolvers(); ContextTypeRegistry registry = PHPUiPlugin.getDefault().getCodeTemplateContextRegistry(); registry.addContextType(new CodeTemplateContextType(NewSilverStripeTemplatesWizardPage.NEW_SS_TEMPLATE_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(NewSilverStripeTemplatesWizardPage.NEW_SS_30_TEMPLATE_CONTEXTTYPE)); } else { // register listener to get informed, when plug-in becomes active final BundleContext bundleContext = SilverStripePDTPlugin.getDefault().getBundle().getBundleContext(); bundleContext.addBundleListener(new BundleListener() { public void bundleChanged(final BundleEvent pEvent) { final Bundle bundle2 = pEvent.getBundle(); if (!bundle2.getSymbolicName().equals(SilverStripePDTPlugin.PLUGIN_ID)) { return; } if (bundle2.getState() == Bundle.ACTIVE) { registerResolvers(); bundleContext.removeBundleListener(this); } } }); } }
public SSEditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, ContextTypeRegistry registry) { super(parent, template, edit, isNameModifiable, registry); this.fNewTemplate=null; if(template instanceof SilverStripeTemplate) { this.fOriginalTemplate=(SilverStripeTemplate) template; } }
protected String getTemplatesLocationMessage() { ContextTypeRegistry templateContextRegistry = getTemplatesContextTypeRegistry(); if(this._languageProvider==null) { return ""; } TemplateContextType templateContextType = templateContextRegistry.getContextType(this._languageProvider.getTemplateContext()); String name = templateContextType.getName(); return NLS.bind("Templates are \"{0}\" found in the <a>SilverStripe Templates</a> preference page.", name); }
protected String getTemplatesLocationMessage() { ContextTypeRegistry templateContextRegistry = getTemplatesContextTypeRegistry(); TemplateContextType templateContextType = templateContextRegistry.getContextType(getTemplateContextTypeId()); String name = templateContextType.getName(); return NLS.bind("Templates are \"{0}\" found in the <a>SilverStripe Templates</a> preference page.", name); }
protected ContextTypeRegistry createContributionContextTypeRegistry() { final ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry(); for(String id : getRegisteredContextTypeIds()) { registry.addContextType(id); } return registry; }