use of org.eclipse.jface.text.templates.TemplateContextType in project eclipse.platform.text by eclipse.
the class TemplatePreferencePage method add.
private void add() {
Iterator<TemplateContextType> it = fContextTypeRegistry.contextTypes();
if (it.hasNext()) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Template template = new Template("", "", it.next().getId(), "", true);
Template newTemplate = editTemplate(template, false, true);
if (newTemplate != null) {
TemplatePersistenceData data = new TemplatePersistenceData(newTemplate, true);
fTemplateStore.add(data);
fTableViewer.refresh();
fTableViewer.setChecked(data, true);
fTableViewer.setSelection(new StructuredSelection(data));
}
}
}
use of org.eclipse.jface.text.templates.TemplateContextType in project erlide_eclipse by erlang.
the class ErlTemplateCompletionProcessor method getTemplates.
@Override
protected Template[] getTemplates(final String contextTypeId) {
final Template[] templates = ErlideUIPlugin.getDefault().getTemplateStore().getTemplates();
final TemplateContextType type = ErlideUIPlugin.getDefault().getContextTypeRegistry().getContextType(contextTypeId);
if (type instanceof ErlangTemplateContextType) {
final List<Template> result = new ArrayList<>(templates.length);
final ErlangTemplateContext etc = new ErlangTemplateContext(type, fDocument, offset, length);
for (final Template template : templates) {
if (etc.canEvaluate(template)) {
result.add(template);
}
}
return result.toArray(new Template[result.size()]);
}
return templates;
}
use of org.eclipse.jface.text.templates.TemplateContextType in project liferay-ide by liferay.
the class NewLayoutTplWizard method getDefaultProvider.
@Override
protected IDataModelProvider getDefaultProvider() {
LayoutTplUI defaultUI = LayoutTplUI.getDefault();
TemplateStore templateStore = defaultUI.getTemplateStore();
ContextTypeRegistry contextTypeRegistry = defaultUI.getTemplateContextRegistry();
TemplateContextType contextType = contextTypeRegistry.getContextType(LayoutTplTemplateContextTypeIds.NEW);
return new NewLayoutTplDataModelProvider() {
@Override
public IDataModelOperation getDefaultOperation() {
return new AddLayoutTplOperation(getDataModel(), templateStore, contextType);
}
};
}
use of org.eclipse.jface.text.templates.TemplateContextType in project liferay-ide by liferay.
the class LiferayUIPlugin method _registerResolvers.
private void _registerResolvers() {
ContextTypeRegistry templateContextRegistry = JavaPlugin.getDefault().getTemplateContextRegistry();
Iterator<?> ctIter = templateContextRegistry.contextTypes();
while (ctIter.hasNext()) {
Object next = ctIter.next();
if (next instanceof TemplateContextType) {
TemplateContextType contextType = (TemplateContextType) next;
if (contextType.getId().equals("java")) {
contextType.addResolver(new ServiceClassNameResolver());
}
}
}
}
use of org.eclipse.jface.text.templates.TemplateContextType in project liferay-ide by liferay.
the class ServiceXmlTemplateCompletinoProcessor method getContextType.
@Override
protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
TemplateContextType type = null;
ContextTypeRegistry registry = getTemplateContextRegistry();
if (registry != null) {
type = registry.getContextType(ServiceXmlContextType.ID_SERVICE_XML_TAG);
}
return type;
}
Aggregations