本文整理汇总了Java中org.eclipse.jface.text.templates.persistence.TemplatePersistenceData.getId方法的典型用法代码示例。如果您正苦于以下问题:Java TemplatePersistenceData.getId方法的具体用法?Java TemplatePersistenceData.getId怎么用?Java TemplatePersistenceData.getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.templates.persistence.TemplatePersistenceData
的用法示例。
在下文中一共展示了TemplatePersistenceData.getId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: directAdd
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
public void directAdd(final TemplatePersistenceData data, final boolean isEdited) {
if (isEdited) {
add(data);
} else {
// Trick the template store so that (1) the template is considered
// as "user added" while (2) maintaining a proper id
final String id = data.getId();
final TemplatePersistenceData d2 = new TemplatePersistenceData(data.getTemplate(), true) {
@Override
public String getId() {
return id;
}
};
add(d2);
}
}
示例2: load
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
public void load() throws IOException {
if (fProjectStore != null) {
fProjectStore.load();
Set<String> datas= new HashSet<String>();
TemplatePersistenceData[] data= fProjectStore.getTemplateData(false);
for (int i= 0; i < data.length; i++) {
datas.add(data[i].getId());
}
data= fInstanceStore.getTemplateData(false);
for (int i= 0; i < data.length; i++) {
TemplatePersistenceData orig= data[i];
if (!datas.contains(orig.getId())) {
TemplatePersistenceData copy= new TemplatePersistenceData(new Template(orig.getTemplate()), orig.isEnabled(), orig.getId());
fProjectStore.add(copy);
copy.setDeleted(true);
}
}
}
}
示例3: addTemplatesFromFile
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
/**
* Contribute templates defined in file with the give URL.
*
* @param templates
* the URL of the file with templates
*/
private void addTemplatesFromFile(final URL templates) {
if (templates != null) {
TemplateReaderWriter reader = new TemplateReaderWriter();
try {
InputStream openStream = templates.openStream();
try {
TemplatePersistenceData[] datas = reader.read(openStream, null);
int templateCounter = 0;
for (TemplatePersistenceData data : datas) {
if (data.getId() == null) {
templateCounter++;
TemplatePersistenceData dataWithGenId = new TemplatePersistenceData(data.getTemplate(), data.isEnabled(), templates.getPath() + "." //$NON-NLS-1$
+ templateCounter);
dataWithGenId.setDeleted(data.isDeleted());
internalAdd(dataWithGenId);
} else {
// if contributed template has an id
internalAdd(data);
}
}
} finally {
openStream.close();
}
} catch (IOException e) {
LOG.error(e);
}
}
}
示例4: category
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
public int category(Object element) {
if (element == COMMENT_NODE) {
return 1;
} else if (element == CODE_NODE) {
return 2;
}
TemplatePersistenceData data = (TemplatePersistenceData) element;
String id = data.getId();
if (CodeTemplateContextType.NEWTYPE_ID.equals(id)) {
return 101;
} else if (CodeTemplateContextType.CLASSBODY_ID.equals(id)) {
return 102;
} else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
return 106;
} else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id)) {
return 107;
} else if (CodeTemplateContextType.GETTERSTUB_ID.equals(id)) {
return 108;
} else if (CodeTemplateContextType.SETTERSTUB_ID.equals(id)) {
return 109;
} else if (CodeTemplateContextType.CATCHBLOCK_ID.equals(id)) {
return 110;
} else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
return 1;
} else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
return 2;
} else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
return 3;
} else if (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
return 4;
} else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
return 5;
} else if (CodeTemplateContextType.OVERRIDECOMMENT_ID.equals(id)) {
return 6;
} else if (CodeTemplateContextType.DELEGATECOMMENT_ID.equals(id)) {
return 7;
} else if (CodeTemplateContextType.GETTERCOMMENT_ID.equals(id)) {
return 8;
} else if (CodeTemplateContextType.SETTERCOMMENT_ID.equals(id)) {
return 9;
}
return 1000;
}
示例5: getText
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
public String getText(Object element) {
if (element == COMMENT_NODE || element == CODE_NODE) {
return (String) element;
}
TemplatePersistenceData data = (TemplatePersistenceData) element;
String id = data.getId();
// if (CodeTemplateContextType.CATCHBLOCK_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_catchblock_label;
// } else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_methodstub_label;
// } else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id))
// {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_constructorstub_label;
// } else if (CodeTemplateContextType.GETTERSTUB_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_getterstub_label;
// } else if (CodeTemplateContextType.SETTERSTUB_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_setterstub_label;
// } else if (CodeTemplateContextType.NEWTYPE_ID.equals(id)) {
// return JSDTTypeScriptUIMessages.CodeTemplateBlock_newtype_label;
// } else if (CodeTemplateContextType.CLASSBODY_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_classbody_label;
// } else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_filecomment_label;
// } else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_typecomment_label;
// } else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_fieldcomment_label;
// } else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_methodcomment_label;
// } else if (CodeTemplateContextType.OVERRIDECOMMENT_ID.equals(id))
// {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_overridecomment_label;
// } else if (CodeTemplateContextType.DELEGATECOMMENT_ID.equals(id))
// {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_delegatecomment_label;
// } else if
// (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_constructorcomment_label;
// } else if (CodeTemplateContextType.GETTERCOMMENT_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_gettercomment_label;
// } else if (CodeTemplateContextType.SETTERCOMMENT_ID.equals(id)) {
// return
// JSDTTypeScriptUIMessages.CodeTemplateBlock_settercomment_label;
// }
return data.getTemplate().getDescription();
}
示例6: add
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
void add(final TemplatePersistenceData t) {
final String id = t.getId();
final List<String> path = new ArrayList<>(Arrays.asList(id.split("\\.")));
add(t, path);
}
示例7: category
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
@Override
public int category(Object element) {
if (element == COMMENT_NODE) {
return 1;
} else if (element == CODE_NODE) {
return 2;
}
TemplatePersistenceData data= (TemplatePersistenceData) element;
String id= data.getId();
if (CodeTemplateContextType.NEWTYPE_ID.equals(id)) {
return 101;
} else if (CodeTemplateContextType.CLASSBODY_ID.equals(id)) {
return 102;
} else if (CodeTemplateContextType.INTERFACEBODY_ID.equals(id)) {
return 103;
} else if (CodeTemplateContextType.ENUMBODY_ID.equals(id)) {
return 104;
} else if (CodeTemplateContextType.ANNOTATIONBODY_ID.equals(id)) {
return 105;
} else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
return 106;
} else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id)) {
return 107;
} else if (CodeTemplateContextType.GETTERSTUB_ID.equals(id)) {
return 108;
} else if (CodeTemplateContextType.SETTERSTUB_ID.equals(id)) {
return 109;
} else if (CodeTemplateContextType.CATCHBLOCK_ID.equals(id)) {
return 110;
} else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
return 1;
} else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
return 2;
} else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
return 3;
} else if (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
return 4;
} else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
return 5;
} else if (CodeTemplateContextType.OVERRIDECOMMENT_ID.equals(id)) {
return 6;
} else if (CodeTemplateContextType.DELEGATECOMMENT_ID.equals(id)) {
return 7;
} else if (CodeTemplateContextType.GETTERCOMMENT_ID.equals(id)) {
return 8;
} else if (CodeTemplateContextType.SETTERCOMMENT_ID.equals(id)) {
return 9;
}
return 1000;
}
示例8: getText
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; //导入方法依赖的package包/类
@Override
public String getText(Object element) {
if (element == COMMENT_NODE || element == CODE_NODE) {
return (String) element;
}
TemplatePersistenceData data= (TemplatePersistenceData) element;
String id=data.getId();
if (CodeTemplateContextType.CATCHBLOCK_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_catchblock_label;
} else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_methodstub_label;
} else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_constructorstub_label;
} else if (CodeTemplateContextType.GETTERSTUB_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_getterstub_label;
} else if (CodeTemplateContextType.SETTERSTUB_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_setterstub_label;
} else if (CodeTemplateContextType.NEWTYPE_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_newtype_label;
} else if (CodeTemplateContextType.CLASSBODY_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_classbody_label;
} else if (CodeTemplateContextType.INTERFACEBODY_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_interfacebody_label;
} else if (CodeTemplateContextType.ENUMBODY_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_enumbody_label;
} else if (CodeTemplateContextType.ANNOTATIONBODY_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_annotationbody_label;
} else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_filecomment_label;
} else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_typecomment_label;
} else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_fieldcomment_label;
} else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_methodcomment_label;
} else if (CodeTemplateContextType.OVERRIDECOMMENT_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_overridecomment_label;
} else if (CodeTemplateContextType.DELEGATECOMMENT_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_delegatecomment_label;
} else if (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_constructorcomment_label;
} else if (CodeTemplateContextType.GETTERCOMMENT_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_gettercomment_label;
} else if (CodeTemplateContextType.SETTERCOMMENT_ID.equals(id)) {
return PreferencesMessages.CodeTemplateBlock_settercomment_label;
}
return data.getTemplate().getDescription();
}