use of org.talend.designer.codegen.config.EInternalTemplate in project tdi-studio-se by Talend.
the class CodeGeneratorInternalTemplatesFactory method getTemplatesFrom.
public static List<TemplateUtil> getTemplatesFrom(String pluginId, String directory) {
List<TemplateUtil> templates = new ArrayList<>();
try {
// System.out.println("plugin:" + pluginId); //$NON-NLS-1$
// $NON-NLS-1$
URL url = FileLocator.find(Platform.getBundle(pluginId), new Path(directory), null);
File fileDirectory = new File(FileLocator.toFileURL(url).getPath());
for (File file : fileDirectory.listFiles()) {
EInternalTemplate curentTemplate = null;
if (file.getName().contains(EInternalTemplate.HEADER_ADDITIONAL.getTemplateName()) && file.getName().endsWith(TemplateUtil.EXT_SEP + ECodeLanguage.JAVA.getExtension() + TemplateUtil.TEMPLATE_EXT)) {
curentTemplate = EInternalTemplate.HEADER_ADDITIONAL;
} else {
for (EInternalTemplate utilTemplate : EInternalTemplate.values()) {
if (file.getName().equals(utilTemplate.getTemplateName() + TemplateUtil.EXT_SEP + ECodeLanguage.JAVA.getExtension() + TemplateUtil.TEMPLATE_EXT)) {
curentTemplate = utilTemplate;
break;
}
}
}
if (curentTemplate != null) {
TemplateUtil template = new TemplateUtil(curentTemplate);
template.setJetPluginRepository(pluginId);
template.setTemplateRelativeUri(directory + TemplateUtil.DIR_SEP + file.getName());
templates.add(template);
// System.out.println("----template:" + file.getName()); //$NON-NLS-1$
}
}
} catch (IOException e) {
ExceptionHandler.process(e);
}
return templates;
}
Aggregations