Search in sources :

Example 26 with TemplateContextType

use of org.eclipse.jface.text.templates.TemplateContextType in project webtools.sourceediting by eclipse.

the class XPathTemplateCompletionProcessor method getContextType.

protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
    TemplateContextType type = null;
    ContextTypeRegistry registry = getTemplateContextRegistry();
    if (registry != null) {
        type = registry.getContextType(fContextTypeId);
    }
    return type;
}
Also used : ContextTypeRegistry(org.eclipse.jface.text.templates.ContextTypeRegistry) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType)

Example 27 with TemplateContextType

use of org.eclipse.jface.text.templates.TemplateContextType in project webtools.sourceediting by eclipse.

the class XMLTemplateCompletionProcessor method getContextType.

protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
    TemplateContextType type = null;
    ContextTypeRegistry registry = getTemplateContextRegistry();
    if (registry != null) {
        type = registry.getContextType(fContextTypeId);
    }
    return type;
}
Also used : ContextTypeRegistry(org.eclipse.jface.text.templates.ContextTypeRegistry) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType)

Example 28 with TemplateContextType

use of org.eclipse.jface.text.templates.TemplateContextType in project flux by eclipse.

the class ContributionContextTypeRegistry method createContextType.

private static TemplateContextType createContextType(IConfigurationElement element) throws CoreException {
    String id = element.getAttribute(ID);
    try {
        TemplateContextType contextType = (TemplateContextType) element.createExecutableExtension(CLASS);
        String name = element.getAttribute(NAME);
        if (name == null)
            name = id;
        if (contextType.getId() == null)
            contextType.setId(id);
        if (contextType.getName() == null)
            contextType.setName(name);
        return contextType;
    } catch (ClassCastException e) {
        // $NON-NLS-1$
        throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "extension does not implement " + TemplateContextType.class.getName(), e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType)

Example 29 with TemplateContextType

use of org.eclipse.jface.text.templates.TemplateContextType in project che by eclipse.

the class ContributionContextTypeRegistry method createContextType.

private static TemplateContextType createContextType(IConfigurationElement element) throws CoreException {
    String id = element.getAttribute(ID);
    try {
        TemplateContextType contextType = (TemplateContextType) element.createExecutableExtension(CLASS);
        String name = element.getAttribute(NAME);
        if (name == null)
            name = id;
        if (contextType.getId() == null)
            contextType.setId(id);
        if (contextType.getName() == null)
            contextType.setName(name);
        return contextType;
    } catch (ClassCastException e) {
        //$NON-NLS-1$
        throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.ui.editors", IStatus.OK, "extension does not implement " + TemplateContextType.class.getName(), e));
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType)

Example 30 with TemplateContextType

use of org.eclipse.jface.text.templates.TemplateContextType in project che by eclipse.

the class ContributionContextTypeRegistry method addContextType.

/**
	 * Tries to create a context type given an id. If there is already a context
	 * type registered under the given id, nothing happens. Otherwise,
	 * contributions to the <code>org.eclipse.ui.editors.templates</code>
	 * extension point are searched for the given identifier and the specified
	 * context type instantiated if it is found.
	 *
	 * @param id the id for the context type as specified in XML
	 */
public void addContextType(String id) {
    Assert.isNotNull(id);
    if (getContextType(id) != null)
        return;
    TemplateContextType type = createContextType(id);
    if (type != null)
        addContextType(type);
}
Also used : TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType)

Aggregations

TemplateContextType (org.eclipse.jface.text.templates.TemplateContextType)54 ContextTypeRegistry (org.eclipse.jface.text.templates.ContextTypeRegistry)17 Template (org.eclipse.jface.text.templates.Template)14 Document (org.eclipse.jface.text.Document)11 IDocument (org.eclipse.jface.text.IDocument)11 DocumentTemplateContext (org.eclipse.jface.text.templates.DocumentTemplateContext)9 TemplateVariableResolver (org.eclipse.jface.text.templates.TemplateVariableResolver)9 TemplateBuffer (org.eclipse.jface.text.templates.TemplateBuffer)8 CoreException (org.eclipse.core.runtime.CoreException)7 TemplateContext (org.eclipse.jface.text.templates.TemplateContext)7 IStatus (org.eclipse.core.runtime.IStatus)4 Status (org.eclipse.core.runtime.Status)4 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)4 TemplatePersistenceData (org.eclipse.jface.text.templates.persistence.TemplatePersistenceData)4 TemplateStore (org.eclipse.jface.text.templates.persistence.TemplateStore)4 ContextTypeIdHelper (org.eclipse.xtext.ui.editor.templates.ContextTypeIdHelper)4 IFile (org.eclipse.core.resources.IFile)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StyledString (org.eclipse.jface.viewers.StyledString)3