Java Code Examples for org.eclipse.jface.text.templates.Template#getName()

The following examples show how to use org.eclipse.jface.text.templates.Template#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdvancedTemplatesPreferencePage.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void updateViewerInput() {
	IStructuredSelection selection= (IStructuredSelection) getTableViewer().getSelection();
	if (selection.size() == 1) {
		TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
		Template template= data.getTemplate();
		String name = template.getName();
		TemplateContextType contextType = getContextTypeRegistry().getContextType(template.getContextTypeId());
		if (contextType != null) {
			String prefix = 
					"templates for " + grammarAccess.getGrammar().getName() +
					"'" + name + "'" + " for " + getContextTypeForGrammar(contextType) + ">>";
			String editablePart = template.getPattern();
			String suffix = "";
			partialEditor.updateModel(prefix, editablePart, suffix);
		} else {
			partialEditor.updateModel("", template.getPattern(), "");
		}
	} else {
		partialEditor.updateModel("", "", "");
	}
}
 
Example 2
Source File: DotTemplateProposalProvider.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private Template replaceOpVariable(EObject currentModel,
		Template edgeTemplate) {
	DotGraph dotGraph = EcoreUtil2.getContainerOfType(currentModel,
			DotGraph.class);
	boolean isDirected = dotGraph.getType() == GraphType.DIGRAPH;
	String edgeOp = isDirected ? EdgeOp.DIRECTED.toString()
			: EdgeOp.UNDIRECTED.toString();

	return new Template(edgeTemplate.getName(),
			edgeTemplate.getDescription(), edgeTemplate.getContextTypeId(),
			edgeTemplate.getPattern().replaceAll(Pattern.quote("${op}"), //$NON-NLS-1$
					edgeOp),
			edgeTemplate.isAutoInsertable());
}
 
Example 3
Source File: Activator.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
private Template createNamedTemplate(Template inlineTemplate, String newTemplateId, String key) {
    char[] indentChars = new char[getTabWidth()];
    Arrays.fill(indentChars, ' ');
    String indent = String.valueOf(indentChars);
    
    String newPattern = inlineTemplate.getPattern().replaceAll("\n", "\n" + indent);
    String pattern = String.format("${element_name:element_name('(%s name)')}:\n%s%s", key, indent, newPattern);
    Template template = new Template(inlineTemplate.getName(), //
            inlineTemplate.getDescription(), //
            newTemplateId, //
            pattern, //
            inlineTemplate.isAutoInsertable());
    return template;
}
 
Example 4
Source File: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: AbstractDocumentTemplateContextWithIndent.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
private Template createNewTemplate(Template template, String newString) {
    return new Template(template.getName(), template.getDescription(), template.getContextTypeId(), newString,
            template.isAutoInsertable());
}