use of org.eclipse.jface.text.templates.TemplateContextType in project webtools.sourceediting by eclipse.
the class NewCSSTemplatesWizardPage method getTemplateString.
/**
* Returns template string to insert.
*
* @return String to insert or null if none is to be inserted
*/
String getTemplateString() {
String templateString = null;
Template template = getSelectedTemplate();
if (template != null) {
TemplateContextType contextType = CSSUIPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsCSS.NEW);
IDocument document = new Document();
TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
try {
TemplateBuffer buffer = context.evaluate(template);
templateString = buffer.getString();
} catch (Exception e) {
// $NON-NLS-1$
Logger.log(Logger.WARNING_DEBUG, "Could not create template for new css", e);
}
}
return templateString;
}
use of org.eclipse.jface.text.templates.TemplateContextType in project webtools.sourceediting by eclipse.
the class JSPTemplateCompletionProcessor method getContextType.
protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
TemplateContextType type = null;
ContextTypeRegistry registry = getTemplateContextRegistry();
if (registry != null)
type = registry.getContextType(fContextTypeId);
return type;
}
use of org.eclipse.jface.text.templates.TemplateContextType in project webtools.sourceediting by eclipse.
the class NewDTDTemplatesWizardPage method getTemplateString.
/**
* Returns template string to insert.
*
* @return String to insert or null if none is to be inserted
*/
String getTemplateString() {
String templateString = null;
Template template = getSelectedTemplate();
if (template != null) {
TemplateContextType contextType = DTDUIPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsDTD.NEW);
IDocument document = new Document();
TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
try {
TemplateBuffer buffer = context.evaluate(template);
templateString = buffer.getString();
} catch (Exception e) {
// $NON-NLS-1$
Logger.log(Logger.WARNING_DEBUG, "Could not create template for new dtd", e);
}
}
return templateString;
}
use of org.eclipse.jface.text.templates.TemplateContextType in project webtools.sourceediting by eclipse.
the class XSLTemplateCompletionProcessor method getContextType.
@Override
protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
TemplateContextType type = null;
ContextTypeRegistry registry = getTemplateContextRegistry();
if (registry != null) {
type = registry.getContextType(fContextTypeId);
}
return type;
}
use of org.eclipse.jface.text.templates.TemplateContextType in project webtools.sourceediting by eclipse.
the class NewXMLTemplatesWizardPage method getTemplateString.
/**
* Returns template string to insert.
*
* @return String to insert or null if none is to be inserted
*/
String getTemplateString() {
String templateString = null;
Template template = getSelectedTemplate();
if (template != null) {
TemplateContextType contextType = XMLUIPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsXML.NEW);
IDocument document = new Document();
TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
try {
TemplateBuffer buffer = context.evaluate(template);
templateString = buffer.getString();
} catch (Exception e) {
// $NON-NLS-1$
Logger.log(Logger.WARNING_DEBUG, "Could not create template for new xml", e);
}
}
return templateString;
}
Aggregations