本文整理汇总了Java中org.eclipse.jface.text.templates.Template.getContextTypeId方法的典型用法代码示例。如果您正苦于以下问题:Java Template.getContextTypeId方法的具体用法?Java Template.getContextTypeId怎么用?Java Template.getContextTypeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.templates.Template
的用法示例。
在下文中一共展示了Template.getContextTypeId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSetterMethodBodyContent
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getSetterMethodBodyContent(IJavaProject project, String destTypeName, String methodName, String fieldName, String paramName, String lineDelimiter) throws CoreException {
CodeGenerationTemplate templateSetting = CodeGenerationTemplate.SETTERBOY;
Template template = templateSetting.createTemplate(project);
if (template == null) {
return null;
}
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, destTypeName);
context.setVariable(CodeTemplateContextType.FIELD, fieldName);
context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldName);
context.setVariable(CodeTemplateContextType.PARAM, paramName);
return evaluateTemplate(context, template);
}
示例2: getSetterComment
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getSetterComment(ICompilationUnit cu, String typeName, String methodName, String fieldName, String fieldType, String paramName, String bareFieldName, String lineDelimiter) throws CoreException {
CodeGenerationTemplate templateSetting = CodeGenerationTemplate.SETTERCOMMENT;
Template template = templateSetting.createTemplate(cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
context.setCompilationUnitVariables(cu);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
context.setVariable(CodeTemplateContextType.FIELD, fieldName);
context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldType);
context.setVariable(CodeTemplateContextType.BARE_FIELD_NAME, bareFieldName);
context.setVariable(CodeTemplateContextType.PARAM, paramName);
return evaluateTemplate(context, template);
}
示例3: getGetterComment
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getGetterComment(ICompilationUnit cu, String typeName, String methodName, String fieldName, String fieldType, String bareFieldName, String lineDelimiter) throws CoreException {
CodeGenerationTemplate templateSetting = CodeGenerationTemplate.GETTERCOMMENT;
Template template = templateSetting.createTemplate(cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
context.setCompilationUnitVariables(cu);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
context.setVariable(CodeTemplateContextType.FIELD, fieldName);
context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldType);
context.setVariable(CodeTemplateContextType.BARE_FIELD_NAME, bareFieldName);
return evaluateTemplate(context, template);
}
示例4: getColumnText
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public String getColumnText(Object element, int columnIndex) {
TemplatePersistenceData data = (TemplatePersistenceData) element;
Template template= data.getTemplate();
switch (columnIndex) {
case 0:
return template.getName();
case 1:
TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId());
if (type != null)
return type.getName();
return template.getContextTypeId();
case 2:
return template.getDescription();
case 3:
return template.isAutoInsertable() ? TemplatesMessages.TemplatePreferencePage_on : ""; //$NON-NLS-1$
default:
return ""; //$NON-NLS-1$
}
}
示例5: getGetterMethodBodyContent
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getGetterMethodBodyContent(
IJavaProject project,
String destTypeName,
String methodName,
String fieldName,
String lineDelimiter)
throws CoreException {
String templateName = CodeTemplateContextType.GETTERSTUB_ID;
Template template = getCodeTemplate(templateName, project);
if (template == null) {
return null;
}
CodeTemplateContext context =
new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, destTypeName);
context.setVariable(CodeTemplateContextType.FIELD, fieldName);
return evaluateTemplate(context, template);
}
示例6: getSetterMethodBodyContent
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getSetterMethodBodyContent(
IJavaProject project,
String destTypeName,
String methodName,
String fieldName,
String paramName,
String lineDelimiter)
throws CoreException {
String templateName = CodeTemplateContextType.SETTERSTUB_ID;
Template template = getCodeTemplate(templateName, project);
if (template == null) {
return null;
}
CodeTemplateContext context =
new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, destTypeName);
context.setVariable(CodeTemplateContextType.FIELD, fieldName);
context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldName);
context.setVariable(CodeTemplateContextType.PARAM, paramName);
return evaluateTemplate(context, template);
}
示例7: getCatchBodyContent
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getCatchBodyContent(
ICompilationUnit cu,
String exceptionType,
String variableName,
String enclosingType,
String enclosingMethod,
String lineDelimiter)
throws CoreException {
Template template = getCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context =
new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, enclosingType);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, enclosingMethod);
context.setVariable(CodeTemplateContextType.EXCEPTION_TYPE, exceptionType);
context.setVariable(CodeTemplateContextType.EXCEPTION_VAR, variableName);
return evaluateTemplate(context, template);
}
示例8: getFileComment
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getFileComment(ICompilationUnit cu, String lineDelimiter)
throws CoreException {
Template template =
getCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, cu.getJavaProject());
if (template == null) {
return null;
}
IJavaProject project = cu.getJavaProject();
CodeTemplateContext context =
new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setCompilationUnitVariables(cu);
context.setVariable(
CodeTemplateContextType.TYPENAME, JavaCore.removeJavaLikeExtension(cu.getElementName()));
return evaluateTemplate(context, template);
}
示例9: getTypeBody
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
/**
* Don't use this method directly, use CodeGeneration.
*
* @param templateID the template id of the type body to get. Valid id's are {@link
* CodeTemplateContextType#CLASSBODY_ID}, {@link CodeTemplateContextType#INTERFACEBODY_ID},
* {@link CodeTemplateContextType#ENUMBODY_ID}, {@link
* CodeTemplateContextType#ANNOTATIONBODY_ID},
* @param cu the compilation unit to which the template is added
* @param typeName the type name
* @param lineDelim the line delimiter to use
* @return return the type body template or <code>null</code>
* @throws CoreException thrown if the template could not be evaluated
* @see org.eclipse.jdt.ui.CodeGeneration#getTypeBody(String, ICompilationUnit, String, String)
*/
public static String getTypeBody(
String templateID, ICompilationUnit cu, String typeName, String lineDelim)
throws CoreException {
if (!VALID_TYPE_BODY_TEMPLATES.contains(templateID)) {
throw new IllegalArgumentException("Invalid code template ID: " + templateID); // $NON-NLS-1$
}
Template template = getCodeTemplate(templateID, cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context =
new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelim);
context.setCompilationUnitVariables(cu);
context.setVariable(CodeTemplateContextType.TYPENAME, typeName);
return evaluateTemplate(context, template);
}
示例10: getFieldComment
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getFieldComment(
ICompilationUnit cu, String typeName, String fieldName, String lineDelimiter)
throws CoreException {
Template template =
getCodeTemplate(CodeTemplateContextType.FIELDCOMMENT_ID, cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context =
new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
context.setCompilationUnitVariables(cu);
context.setVariable(CodeTemplateContextType.FIELD_TYPE, typeName);
context.setVariable(CodeTemplateContextType.FIELD, fieldName);
return evaluateTemplate(context, template);
}
示例11: getGetterComment
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getGetterComment(
ICompilationUnit cu,
String typeName,
String methodName,
String fieldName,
String fieldType,
String bareFieldName,
String lineDelimiter)
throws CoreException {
String templateName = CodeTemplateContextType.GETTERCOMMENT_ID;
Template template = getCodeTemplate(templateName, cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context =
new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
context.setCompilationUnitVariables(cu);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
context.setVariable(CodeTemplateContextType.FIELD, fieldName);
context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldType);
context.setVariable(CodeTemplateContextType.BARE_FIELD_NAME, bareFieldName);
return evaluateTemplate(context, template);
}
示例12: getOverridingMethodComment
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
private String getOverridingMethodComment() {
String templateName = CodeTemplateContextType.OVERRIDECOMMENT_ID;
Template template = getCodeTemplate(templateName);
if (template == null) return ""; // $NON-NLS-1$
CodeTemplateContext context =
new CodeTemplateContext(template.getContextTypeId(), null, "\n"); // $NON-NLS-1$
context.setVariable(CodeTemplateContextType.FILENAME, "Face.java"); // $NON-NLS-1$
context.setVariable(CodeTemplateContextType.PACKAGENAME, "test"); // $NON-NLS-1$
context.setVariable(CodeTemplateContextType.PROJECTNAME, "TestProject"); // $NON-NLS-1$
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, "Face"); // $NON-NLS-1$
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, "method"); // $NON-NLS-1$
context.setVariable(CodeTemplateContextType.RETURN_TYPE, "void"); // $NON-NLS-1$
context.setVariable(
CodeTemplateContextType.SEE_TO_OVERRIDDEN_TAG, "test.IFace#foo()"); // $NON-NLS-1$
return evaluateTemplate(template, context);
}
示例13: getGetterMethodBodyContent
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getGetterMethodBodyContent(IJavaProject project, String destTypeName, String methodName, String fieldName, String lineDelimiter) throws CoreException {
CodeGenerationTemplate templateSetting = CodeGenerationTemplate.GETTERBODY;
Template template = templateSetting.createTemplate(project);
if (template == null) {
return null;
}
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, destTypeName);
context.setVariable(CodeTemplateContextType.FIELD, fieldName);
return evaluateTemplate(context, template);
}
示例14: getCatchBodyContent
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getCatchBodyContent(ICompilationUnit cu, String exceptionType, String variableName, String enclosingType, String enclosingMethod, String lineDelimiter) throws CoreException {
// Template template = getCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, cu.getJavaProject());
CodeGenerationTemplate templateSetting = CodeGenerationTemplate.CATCHBODY;
Template template = templateSetting.createTemplate(cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, enclosingType);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, enclosingMethod);
context.setVariable(CodeTemplateContextType.EXCEPTION_TYPE, exceptionType);
context.setVariable(CodeTemplateContextType.EXCEPTION_VAR, variableName);
return evaluateTemplate(context, template);
}
示例15: getFieldComment
import org.eclipse.jface.text.templates.Template; //导入方法依赖的package包/类
public static String getFieldComment(ICompilationUnit cu, String typeName, String fieldName, String lineDelimiter) throws CoreException {
Template template = CodeGenerationTemplate.FIELDCOMMENT.createTemplate(cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
context.setCompilationUnitVariables(cu);
context.setVariable(CodeTemplateContextType.FIELD_TYPE, typeName);
context.setVariable(CodeTemplateContextType.FIELD, fieldName);
return evaluateTemplate(context, template);
}