for (ContentItem item : sortedItems) {
String templateId = item.getId();
if (!templateIds.contains(templateId)) {
Template template = new Template(item, null);
templates.add(template);
templateIds.add(templateId);
}
}
// Add the Simple Projects
List<SimpleProject> simpleProjects = getSimpleProjects();
templates.addAll(simpleProjects);
if (model.shouldShowSelfHostedProjects()) {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject project : projects) {
IFile templateFile = project.getFile(IContentConstants.TEMPLATE_DATA_FILE_NAME);
IFile wizardFile = project.getFile(IContentConstants.WIZARD_DATA_FILE_NAME);
if (templateFile.exists() && wizardFile.exists()) {
File file = templateFile.getLocation().toFile();
try {
DocumentBuilder documentBuilder = ContentUtil.createDocumentBuilder();
Document document = documentBuilder.parse(file);
Element rootNode = document.getDocumentElement();
if (rootNode != null) {
NodeList children = rootNode.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node childNode = children.item(i);
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
if ("descriptor".equals(childNode.getNodeName())) {
Descriptor descriptor = Descriptor.read(childNode);
ContentItem item = new ContentItem(descriptor.getId(), project);
item.setLocalDescriptor(descriptor);
descriptor.setUrl(project.getName());
ImageDescriptor icon = null;
Template template = new Template(item, icon);
templates.add(template);
}
}
}
}