From 949110f10a1ab33a741d29b1237dff6c4293fd4b Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Thu, 31 Jan 2013 18:17:10 +0400 Subject: [PATCH] project templates schema --- .../platform/templates/IC_templates.xml | 3 +- .../platform/templates/IU_template_groups.xml | 13 ++++++++ .../platform/templates/IU_template_groups.xsd | 32 +++++++++++++++++++ .../templates/RemoteTemplatesFactory.java | 20 ++++++------ 4 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml create mode 100644 java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd diff --git a/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml b/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml index 8da6b26f055a..d8daaec7b869 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml +++ b/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml @@ -1,8 +1,7 @@ diff --git a/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml new file mode 100644 index 000000000000..52446026f3b6 --- /dev/null +++ b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml @@ -0,0 +1,13 @@ + + + Spring + Spring + + + \ No newline at end of file diff --git a/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd new file mode 100644 index 000000000000..c7adb5afba89 --- /dev/null +++ b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java index 67fb5a354d00..e6bd637eb0fd 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java +++ b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java @@ -34,6 +34,7 @@ import com.intellij.util.containers.MultiMap; import com.intellij.util.net.HttpConfigurable; import org.jdom.Element; import org.jdom.JDOMException; +import org.jdom.Namespace; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,6 +53,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { private static final String URL = "http://download.jetbrains.com/idea/project_templates/"; private static final String SAMPLES_GALLERY = "Samples Gallery"; + private static final Namespace NAMESPACE = Namespace.getNamespace("http://www.jetbrains.com/projectTemplates"); private final ClearableLazyValue> myTemplates = new ClearableLazyValue>() { @NotNull @Override @@ -104,14 +106,14 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { public static MultiMap createFromText(String text) throws IOException, JDOMException { Element rootElement = JDOMUtil.loadDocument(text).getRootElement(); - List groups = rootElement.getChildren("group"); + List groups = rootElement.getChildren("group", NAMESPACE); MultiMap map = new MultiMap(); if (groups.isEmpty()) { // sample gallery by default - map.put(SAMPLES_GALLERY, createGroupTemplates(rootElement)); + map.put(SAMPLES_GALLERY, createGroupTemplates(rootElement, Namespace.NO_NAMESPACE)); } else { for (Element group : groups) { - map.put(group.getChildText("name"), createGroupTemplates(group)); + map.put(group.getChildText("name", NAMESPACE), createGroupTemplates(group, NAMESPACE)); } } @@ -119,14 +121,14 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { } @SuppressWarnings("unchecked") - private static List createGroupTemplates(Element groupElement) { - List elements = groupElement.getChildren("template"); + private static List createGroupTemplates(Element groupElement, final Namespace ns) { + List elements = groupElement.getChildren("template", ns); return ContainerUtil.mapNotNull(elements, new NullableFunction() { @Override public ProjectTemplate fun(final Element element) { - List plugins = element.getChildren("requiredPlugin"); + List plugins = element.getChildren("requiredPlugin", ns); for (Element plugin : plugins) { String id = plugin.getTextTrim(); if (!PluginManager.isPluginInstalled(PluginId.getId(id))) { @@ -135,7 +137,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { } String type = element.getChildText("moduleType"); final ModuleType moduleType = ModuleTypeManager.getInstance().findByID(type); - return new ArchivedProjectTemplate(element.getChildTextTrim("name")) { + return new ArchivedProjectTemplate(element.getChildTextTrim("name", ns)) { @Override protected ModuleType getModuleType() { return moduleType; @@ -143,7 +145,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { @Override public ZipInputStream getStream() throws IOException { - String path = element.getChildText("path"); + String path = element.getChildText("path", ns); final HttpURLConnection connection = getConnection(path); return new ZipInputStream(connection.getInputStream()) { @Override @@ -157,7 +159,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory { @Nullable @Override public String getDescription() { - return element.getChildTextTrim("description"); + return element.getChildTextTrim("description", ns); } }; }