本文整理汇总了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]);
}
}
}
示例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));
}
}
示例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);
}
示例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;
}
}
示例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));
}
}