当前位置: 首页>>代码示例>>Java>>正文


Java TemplatePersistenceData.setTemplate方法代码示例

本文整理汇总了Java中org.eclipse.jface.text.templates.persistence.TemplatePersistenceData.setTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java TemplatePersistenceData.setTemplate方法的具体用法?Java TemplatePersistenceData.setTemplate怎么用?Java TemplatePersistenceData.setTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.text.templates.persistence.TemplatePersistenceData的用法示例。


在下文中一共展示了TemplatePersistenceData.setTemplate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pruneDuplicates

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
/**
 * Removes any duplicates from a template store. Duplicate user added templates
 * are copied over their contributed siblings. If isCodeTemplates is true,
 * any user added templates are then removed.
 *
 * @param store
 * @param isCodeTemplates
 */
public static void pruneDuplicates(TemplateStore store, boolean isCodeTemplates) {
	TemplatePersistenceData[] datas= store.getTemplateData(true);
	for (int i= datas.length - 1; i >= 0; i--) {
		TemplatePersistenceData data= datas[i];
		if (data.isUserAdded()) {
			// find a contributed template that is similar and check it
			TemplatePersistenceData similar= findSimilarTemplate(datas, data.getTemplate(), isCodeTemplates);
			if (similar != data && !similar.isUserAdded()) {
				similar.setTemplate(data.getTemplate());
				store.delete(data);
			}
		}
	}

	if (isCodeTemplates) {
		datas= store.getTemplateData(true);
		for (int i= datas.length - 1; i >= 0; i--) {
			if (datas[i].isUserAdded())
				store.delete(datas[i]);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:31,代码来源:CompatibilityTemplateStore.java

示例2: edit

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
private void edit(TemplatePersistenceData data) {
	Template newTemplate = new Template(data.getTemplate());
	EditTemplateDialog dialog = new EditTemplateDialog(getShell(), newTemplate, true, false,
			JavaScriptPlugin.getDefault().getCodeTemplateContextRegistry());
	if (dialog.open() == Window.OK) {
		// changed
		data.setTemplate(dialog.getTemplate());
		fCodeTemplateTree.refresh(data);
		fCodeTemplateTree.selectElements(new StructuredSelection(data));
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:12,代码来源:CodeTemplateBlock.java

示例3: setCodeTemplate

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:StubUtility.java

示例4: load

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
@Override
public void load() throws IOException {
	super.load();

	if (fLegacySet != null) {

		List<Template> legacyTemplates= new ArrayList<Template>(Arrays.asList(fLegacySet.getTemplates()));
		fLegacySet.clear();

		TemplatePersistenceData[] datas= getTemplateData(true);
		for (Iterator<Template> it= legacyTemplates.listIterator(); it.hasNext();) {
			Template t= it.next();
			TemplatePersistenceData orig= findSimilarTemplate(datas, t, isCodeTemplates());
			if (orig == null) { // no contributed match for the old template found
				if (!isCodeTemplates())
					add(new TemplatePersistenceData(t, true));
			} else { // a contributed template seems to be the descendant of the non-id template t
				if (!orig.getTemplate().getPattern().equals(t.getPattern()))
					// add as modified contributed template if changed compared to the original
					orig.setTemplate(t);
			}
		}

		save();
		fLegacySet= null;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:CompatibilityTemplateStore.java

示例5: edit

import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
private void edit(TemplatePersistenceData data) {
	Template newTemplate= new Template(data.getTemplate());
	EditTemplateDialog dialog= new EditTemplateDialog(getShell(), newTemplate, true, false, JavaPlugin.getDefault().getCodeTemplateContextRegistry());
	if (dialog.open() == Window.OK) {
		// changed
		data.setTemplate(dialog.getTemplate());
		fCodeTemplateTree.refresh(data);
		fCodeTemplateTree.selectElements(new StructuredSelection(data));
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:CodeTemplateBlock.java


注:本文中的org.eclipse.jface.text.templates.persistence.TemplatePersistenceData.setTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。