Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2012-01-27 13:40:32 -0500
committerDoug Schaefer2012-01-27 13:41:24 -0500
commit6fcb52fe97166e7599969eeada5ac3beeaec12a2 (patch)
treec221d75583c34029331e78b7e0afd38144929a66
parentf13bdf3b334e088e06f032879ebe20f2836ca414 (diff)
downloadorg.eclipse.cdt-6fcb52fe97166e7599969eeada5ac3beeaec12a2.tar.gz
org.eclipse.cdt-6fcb52fe97166e7599969eeada5ac3beeaec12a2.tar.xz
org.eclipse.cdt-6fcb52fe97166e7599969eeada5ac3beeaec12a2.zip
Add real categories for templates. Organize selection in tree.
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml68
-rw-r--r--build/org.eclipse.cdt.managedbuilder.gnu.ui/templates/projecttemplates/MakefileHelloWorldCCProject/template.properties4
-rw-r--r--core/org.eclipse.cdt.core.tests/plugin.xml53
-rw-r--r--core/org.eclipse.cdt.core/schema/templates.exsd446
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java44
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java92
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java33
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java39
-rw-r--r--core/org.eclipse.cdt.ui.tests/plugin.xml10
-rw-r--r--core/org.eclipse.cdt.ui/plugin.properties2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/TemplateSelectionPage.java206
11 files changed, 720 insertions, 277 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
index 42bb3e9f40..9e0a06463e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
@@ -6741,45 +6741,81 @@
<extension
point="org.eclipse.cdt.core.templates">
<template
- id="org.eclipse.cdt.managedbuilder.core.tests.templates.AppendToMBSStringOptionValue"
filterPattern=".*AppendToMBSStringOptionValue"
+ id="org.eclipse.cdt.managedbuilder.core.tests.templates.AppendToMBSStringOptionValue"
location="testdata/AppendToMBSStringOptionValue.xml"
- projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.managedbuilder.core.tests.mbsTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.managedbuilder.core.tests.templates.AppendToMBSStringListOptionValues"
filterPattern=".*AppendToMBSStringListOptionValues"
+ id="org.eclipse.cdt.managedbuilder.core.tests.templates.AppendToMBSStringListOptionValues"
location="testdata/AppendToMBSStringListOptionValues.xml"
- projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.managedbuilder.core.tests.mbsTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.managedbuilder.core.tests.templates.CreateIncludeFolder"
filterPattern=".*CreateIncludeFolder"
+ id="org.eclipse.cdt.managedbuilder.core.tests.templates.CreateIncludeFolder"
location="testdata/CreateIncludeFolder.xml"
- projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.managedbuilder.core.tests.mbsTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.managedbuilder.core.tests.templates.ExcludeResources"
filterPattern=".*ExcludeResources"
+ id="org.eclipse.cdt.managedbuilder.core.tests.templates.ExcludeResources"
location="testdata/ExcludeResources.xml"
- projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.managedbuilder.core.tests.mbsTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.managedbuilder.core.tests.templates.NewManagedProject"
filterPattern=".*NewManagedProject"
+ id="org.eclipse.cdt.managedbuilder.core.tests.templates.NewManagedProject"
location="testdata/NewManagedProject.xml"
- projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.managedbuilder.core.tests.mbsTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSBooleanOptionValue"
filterPattern=".*SetMBSBooleanOptionValue"
+ id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSBooleanOptionValue"
location="testdata/SetMBSBooleanOptionValue.xml"
- projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.managedbuilder.core.tests.mbsTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSStringOptionValue"
filterPattern=".*SetMBSStringOptionValue"
+ id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSStringOptionValue"
location="testdata/SetMBSStringOptionValue.xml"
- projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.managedbuilder.core.tests.mbsTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSStringListOptionValues"
filterPattern=".*SetMBSStringListOptionValues"
+ id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSStringListOptionValues"
location="testdata/SetMBSStringListOptionValues.xml"
- projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.managedbuilder.core.tests.mbsTests">
+ </parentCategory>
+ </template>
+ <category
+ id="org.eclipse.cdt.managedbuilder.core.tests.mbsTests"
+ label="MBS Tests">
+ </category>
</extension>
<!-- 4.0 tests -->
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/templates/projecttemplates/MakefileHelloWorldCCProject/template.properties b/build/org.eclipse.cdt.managedbuilder.gnu.ui/templates/projecttemplates/MakefileHelloWorldCCProject/template.properties
index aa80740199..9dae766385 100644
--- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/templates/projecttemplates/MakefileHelloWorldCCProject/template.properties
+++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/templates/projecttemplates/MakefileHelloWorldCCProject/template.properties
@@ -10,8 +10,8 @@
###############################################################################
#Template Default Values
-MakefileHelloWorld.CCtemplate.label=Hello World C++ Project
-MakefileHelloWorld.CCtemplate.description=A Hello World C++ Project
+MakefileHelloWorld.CCtemplate.label=Hello World C++ Makefile Project
+MakefileHelloWorld.CCtemplate.description=A Hello World C++ Makefile Project
MakefileHelloWorld.basics.label=Basic Settings
MakefileHelloWorld.basics.description=Basic properties of a project
MakefileHelloWorld.author.label=Author
diff --git a/core/org.eclipse.cdt.core.tests/plugin.xml b/core/org.eclipse.cdt.core.tests/plugin.xml
index bec9aaf4b7..019bccf959 100644
--- a/core/org.eclipse.cdt.core.tests/plugin.xml
+++ b/core/org.eclipse.cdt.core.tests/plugin.xml
@@ -82,6 +82,9 @@
isCategory="true"
location="resources/templateengine/AddFile.xml"
projectType="org.eclipse.cdt.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.core.tests.coreTests">
+ </parentCategory>
</template>
<template
id="org.eclipse.cdt.core.tests.templates.AddFiles"
@@ -90,38 +93,68 @@
projectType="org.eclipse.cdt.core.tests.projectType">
<toolChain id="org.eclipse.cdt.core.tests.toolChain1"/>
<toolChain id="org.eclipse.cdt.core.tests.toolChain2"/>
+ <parentCategory
+ id="org.eclipse.cdt.core.tests.coreTests">
+ </parentCategory>
</template>
<template
id="org.eclipse.cdt.core.tests.templates.AddLink"
filterPattern=".*AddLink"
location="resources/templateengine/AddLink.xml"
projectType="org.eclipse.cdt.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.core.tests.coreTests">
+ </parentCategory>
</template>
<template
- id="org.eclipse.cdt.core.tests.templates.Append"
filterPattern=".*Append"
+ id="org.eclipse.cdt.core.tests.templates.Append"
location="resources/templateengine/Append.xml"
- projectType="org.eclipse.cdt.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.core.tests.coreTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.core.tests.templates.AppendCreate"
filterPattern=".*AppendCreate"
+ id="org.eclipse.cdt.core.tests.templates.AppendCreate"
location="resources/templateengine/AppendCreate.xml"
- projectType="org.eclipse.cdt.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.core.tests.coreTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.core.tests.templates.Copy"
filterPattern=".*Copy"
+ id="org.eclipse.cdt.core.tests.templates.Copy"
location="resources/templateengine/Copy.xml"
- projectType="org.eclipse.cdt.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.core.tests.coreTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.core.tests.templates.CreateResourceIdentifier"
filterPattern=".*CreateResourceIdentifier"
+ id="org.eclipse.cdt.core.tests.templates.CreateResourceIdentifier"
location="resources/templateengine/CreateResourceIdentifier.xml"
- projectType="org.eclipse.cdt.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.core.tests.coreTests">
+ </parentCategory>
+ </template>
<template
- id="org.eclipse.cdt.core.tests.templates.CreateSourceFolder"
filterPattern=".*CreateSourceFolder"
+ id="org.eclipse.cdt.core.tests.templates.CreateSourceFolder"
location="resources/templateengine/CreateSourceFolder.xml"
- projectType="org.eclipse.cdt.core.tests.projectType"/>
+ projectType="org.eclipse.cdt.core.tests.projectType">
+ <parentCategory
+ id="org.eclipse.cdt.core.tests.coreTests">
+ </parentCategory>
+ </template>
+ <category
+ id="org.eclipse.cdt.core.tests.coreTests"
+ label="Core Tests">
+ </category>
</extension>
<extension
point="org.eclipse.cdt.core.templateAssociations">
diff --git a/core/org.eclipse.cdt.core/schema/templates.exsd b/core/org.eclipse.cdt.core/schema/templates.exsd
index e5965ee056..3c0b575038 100644
--- a/core/org.eclipse.cdt.core/schema/templates.exsd
+++ b/core/org.eclipse.cdt.core/schema/templates.exsd
@@ -1,201 +1,245 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.cdt.core">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.cdt.core" id="templates" name="Template Extension point"/>
- </appInfo>
- <documentation>
- This templates extension point facilitates the users to contribute their Template XMLs to the Template Engine plug-in.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <documentation>
- Extension point added to Template Engine plugin. Any plugin, which intends to contribute XML templates to the Template Engine must extend this extension point, and add the template element.
-
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="template" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- Id for the extension in the extender plugin.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- Optional name attribute.
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="template">
- <annotation>
- <documentation>
- By adding the templates extension point the users can contribute their Template XMLs to the Template Engine plugin.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="toolChain" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- A unique identifier for this template contribution. This does not need to be the same as the id of the template (as defined in template.xml) it is contributing. This allows contributing the same template.xml more than once (for example for multiple project types, or with alternate page sequences).
- </documentation>
- </annotation>
- </attribute>
- <attribute name="location" type="string" use="required">
- <annotation>
- <documentation>
- The path of template.xml (relative to the base of the containing plug-in). For example &quot;templates/TemplateOne/template.xml&quot;. This attribute is mandatory.
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="projectType" type="string" use="required">
- <annotation>
- <documentation>
- This attribute is a project type id referring to the cdt project type that the template will be associated with. Project types are contributed to the org.eclipse.cdt.managedbuilder.core.buildDefinitions extension-point.
-This attribute is mandatory. CDT pre-defines the following values of the build artifact type property:
-&lt;ul&gt;
-&lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.exe&quot; - to represent executable
-&lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.staticLib&quot; - to represent static library
-&lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.sharedLib&quot; - to represent shared library
-&lt;li&gt;ISVs can define their own custom build artifact values by contributing to the org.eclipse.cdt.managedbuilder.core.buildProperties extension point.
-&lt;/ul&gt;
- </documentation>
- </annotation>
- </attribute>
- <attribute name="isCategory" type="boolean">
- <annotation>
- <documentation>
- If true this template contribution should appear as a folder. Defaults to false.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="filterPattern" type="string">
- <annotation>
- <documentation>
- filterPattern is a java.util.regex.Pattern format string which is used to match against build configuration ids. This is an optional attribute, if absent will all configurations will match.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="pagesAfterTemplateSelectionProvider" type="string">
- <annotation>
- <documentation>
- A class that implements org.eclipse.cdt.templateengine.IPagesAfterTemplateSelectionProvider interface to create pages that will be appended to the pages returned from TemplatesChoiceWizard.getPagesAfterTemplateSelection().
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.templateengine.IPagesAfterTemplateSelectionProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="toolChain">
- <annotation>
- <documentation>
- This element is used to reference an existing toolchain by its unique identifier.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The unique identifier of a toolchain contributed to the org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- This extension point was added in CDT 4.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- The following is an example of the extension point usage:
-&lt;p&gt;
-&lt;pre&gt;
- &lt;extension point=&quot;org.eclipse.cdt.core.templates&quot;&gt;
- &lt;template
- id=&quot;org.foobar.templates.MyExampleTemplate&quot;
- location=&quot;templates/MyExampleTemplate/template.xml&quot;
- projectType=&quot;org.eclipse.cdt.build.core.buildArtefactType.exe&quot;
- filterPattern=&quot;.*&quot;&gt;
- &lt;/template&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
-
-For more details on how to define your own templates, please check examples provided under &lt;samp&gt;org.eclipse.cdt.ui.templateengine&lt;/samp&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- An implementation of this extension point is supplied in &lt;samp&gt;org.eclipse.cdt.templateengine&lt;/samp&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2007 Symbian Software Limited and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Eclipse Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
-Symbian - Initial API and implementation
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.core" id="templates" name="Template Extension point"/>
+ </appInfo>
+ <documentation>
+ This templates extension point facilitates the users to contribute their Template XMLs to the Template Engine plug-in.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ <documentation>
+ Extension point added to Template Engine plugin. Any plugin, which intends to contribute XML templates to the Template Engine must extend this extension point, and add the template element.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="template" minOccurs="1" maxOccurs="unbounded"/>
+ <element ref="category" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ Id for the extension in the extender plugin.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ Optional name attribute.
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="template">
+ <annotation>
+ <documentation>
+ By adding the templates extension point the users can contribute their Template XMLs to the Template Engine plugin.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="toolChain" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="parentCategory" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ A unique identifier for this template contribution. This does not need to be the same as the id of the template (as defined in template.xml) it is contributing. This allows contributing the same template.xml more than once (for example for multiple project types, or with alternate page sequences).
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="location" type="string" use="required">
+ <annotation>
+ <documentation>
+ The path of template.xml (relative to the base of the containing plug-in). For example &quot;templates/TemplateOne/template.xml&quot;. This attribute is mandatory.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="projectType" type="string">
+ <annotation>
+ <documentation>
+ This attribute is a project type id referring to the cdt project type that the template will be associated with. Project types are contributed to the org.eclipse.cdt.managedbuilder.core.buildDefinitions extension-point.
+This attribute is mandatory. CDT pre-defines the following values of the build artifact type property:
+&lt;ul&gt;
+&lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.exe&quot; - to represent executable
+&lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.staticLib&quot; - to represent static library
+&lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.sharedLib&quot; - to represent shared library
+&lt;li&gt;ISVs can define their own custom build artifact values by contributing to the org.eclipse.cdt.managedbuilder.core.buildProperties extension point.
+&lt;/ul&gt;
+It&apos;s no longer manditory since templates are no longer organized by project type. Template catogories replace that functionality.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="isCategory" type="boolean">
+ <annotation>
+ <documentation>
+ If true this template contribution should appear as a folder. Defaults to false.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="filterPattern" type="string">
+ <annotation>
+ <documentation>
+ filterPattern is a java.util.regex.Pattern format string which is used to match against build configuration ids. This is an optional attribute, if absent will all configurations will match.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="pagesAfterTemplateSelectionProvider" type="string">
+ <annotation>
+ <documentation>
+ A class that implements org.eclipse.cdt.templateengine.IPagesAfterTemplateSelectionProvider interface to create pages that will be appended to the pages returned from TemplatesChoiceWizard.getPagesAfterTemplateSelection().
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.templateengine.IPagesAfterTemplateSelectionProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toolChain">
+ <annotation>
+ <documentation>
+ This element is used to reference an existing toolchain by its unique identifier.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The unique identifier of a toolchain contributed to the org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="category">
+ <annotation>
+ <documentation>
+ Used to arrange templates in a hierarchy in the UI.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="parentCategory" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="parentCategory">
+ <annotation>
+ <documentation>
+ id of parent category.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ This extension point was added in CDT 4.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ The following is an example of the extension point usage:
+&lt;p&gt;
+&lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.cdt.core.templates&quot;&gt;
+ &lt;template
+ id=&quot;org.foobar.templates.MyExampleTemplate&quot;
+ location=&quot;templates/MyExampleTemplate/template.xml&quot;
+ projectType=&quot;org.eclipse.cdt.build.core.buildArtefactType.exe&quot;
+ filterPattern=&quot;.*&quot;&gt;
+ &lt;/template&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+
+For more details on how to define your own templates, please check examples provided under &lt;samp&gt;org.eclipse.cdt.ui.templateengine&lt;/samp&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ An implementation of this extension point is supplied in &lt;samp&gt;org.eclipse.cdt.templateengine&lt;/samp&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2007 Symbian Software Limited and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+Symbian - Initial API and implementation
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java
new file mode 100644
index 0000000000..265ee19d3a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCategory.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Doug Schaefer - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.templateengine;
+
+import java.util.List;
+
+/**
+ * @author Doug Schaefer
+ * @since 5.4
+ */
+public class TemplateCategory {
+
+ private final String id;
+ private String label;
+ private List<String> parentCategoryIds;
+
+ public TemplateCategory(String id, String label, List<String> parentCategoryIds) {
+ this.id = id;
+ this.label = label;
+ this.parentCategoryIds = parentCategoryIds;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public List<String> getParentCategoryIds() {
+ return parentCategoryIds;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java
index 54b8589731..1ffac0e36e 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java
@@ -53,13 +53,15 @@ public class TemplateEngine {
/**
* This is a Map <WizardID, TemplateInfo>.
*/
- private Map<String, List<TemplateInfo>> templateInfoMap;
+ private Map<String, List<TemplateInfo>> templateInfoMap = new LinkedHashMap<String, List<TemplateInfo>>();
+
+ Map<String, TemplateCategory> categoryMap = new HashMap<String, TemplateCategory>();
+
/**
* TemplateEngine constructor, create and initialise SharedDefaults.
*/
- private TemplateEngine() {
- templateInfoMap = new LinkedHashMap<String, List<TemplateInfo>>();
+ TemplateEngine() {
initializeTemplateInfoMap();
}
@@ -190,7 +192,7 @@ public class TemplateEngine {
*/
public static TemplateEngine getDefault() {
if(TEMPLATE_ENGINE==null) {
- TEMPLATE_ENGINE = new TemplateEngine();
+ TEMPLATE_ENGINE = new TemplateEngine2();
}
return TEMPLATE_ENGINE;
}
@@ -201,48 +203,62 @@ public class TemplateEngine {
* extension point "templates"
*/
private void initializeTemplateInfoMap() {
- String templateId = null;
- String location = null;
- String pluginId = null;
- String projectType = null;
- String filterPattern = null;
- boolean isCategory = false;
-
IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(TEMPLATES_EXTENSION_ID).getExtensions();
for(int i=0; i<extensions.length; i++) {
IExtension extension = extensions[i];
IConfigurationElement[] configElements = extension.getConfigurationElements();
- pluginId = extension.getNamespaceIdentifier(); // Plug-in id of the extending plug-in.
+ String pluginId = extension.getNamespaceIdentifier(); // Plug-in id of the extending plug-in.
for(int j=0; j<configElements.length; j++) {
- Object /*IPagesAfterTemplateSelectionProvider*/ extraPagesProvider = null;
IConfigurationElement config = configElements[j];
- templateId = config.getAttribute(TemplateEngineHelper.ID);
- location = config.getAttribute(TemplateEngineHelper.LOCATION);
- projectType = config.getAttribute(TemplateEngineHelper.PROJECT_TYPE);
- filterPattern = config.getAttribute(TemplateEngineHelper.FILTER_PATTERN);
- isCategory = Boolean.valueOf(config.getAttribute(TemplateEngineHelper.IS_CATEGORY)).booleanValue();
- String providerAttribute = config.getAttribute(TemplateEngineHelper.EXTRA_PAGES_PROVIDER);
- if (providerAttribute != null) {
- try {
- extraPagesProvider = config.createExecutableExtension(TemplateEngineHelper.EXTRA_PAGES_PROVIDER);
- } catch (CoreException e) {
- CCorePlugin.log(CCorePlugin.createStatus("Unable to create extra pages for "+providerAttribute,e)); //$NON-NLS-1$
- }
- }
+ String configName = config.getName();
+ if (configName.equals("template")) { //$NON-NLS-1$
+ Object /*IPagesAfterTemplateSelectionProvider*/ extraPagesProvider = null;
+ String templateId = config.getAttribute(TemplateEngineHelper.ID);
+ String location = config.getAttribute(TemplateEngineHelper.LOCATION);
+ String projectType = config.getAttribute(TemplateEngineHelper.PROJECT_TYPE);
+ if (projectType == null || projectType.isEmpty())
+ projectType = TemplateEngine2.NEW_TEMPLATE;
+ String filterPattern = config.getAttribute(TemplateEngineHelper.FILTER_PATTERN);
+ boolean isCategory = Boolean.valueOf(config.getAttribute(TemplateEngineHelper.IS_CATEGORY)).booleanValue();
+ String providerAttribute = config.getAttribute(TemplateEngineHelper.EXTRA_PAGES_PROVIDER);
+ if (providerAttribute != null) {
+ try {
+ extraPagesProvider = config.createExecutableExtension(TemplateEngineHelper.EXTRA_PAGES_PROVIDER);
+ } catch (CoreException e) {
+ CCorePlugin.log(CCorePlugin.createStatus("Unable to create extra pages for "+providerAttribute,e)); //$NON-NLS-1$
+ }
+ }
+
+ IConfigurationElement[] toolChainConfigs = config.getChildren(TemplateEngineHelper.TOOL_CHAIN);
+ Set<String> toolChainIdSet = new LinkedHashSet<String>();
+ for (IConfigurationElement toolChainConfig : toolChainConfigs)
+ toolChainIdSet.add(toolChainConfig.getAttribute(TemplateEngineHelper.ID));
+
+ IConfigurationElement[] parentCategoryConfigs = config.getChildren("parentCategory"); //$NON-NLS-1$
+ List<String> parentCategoryIds = new ArrayList<String>();
+ for (IConfigurationElement parentCategoryConfig : parentCategoryConfigs)
+ parentCategoryIds.add(parentCategoryConfig.getAttribute("id")); //$NON-NLS-1$
+
+ TemplateInfo templateInfo = new TemplateInfo2(templateId, projectType, filterPattern, location,
+ pluginId, toolChainIdSet,
+ extraPagesProvider, isCategory, parentCategoryIds);
+ if (!templateInfoMap.containsKey(projectType)) {
+ templateInfoMap.put(projectType, new ArrayList<TemplateInfo>());
+ }
+ (templateInfoMap.get(projectType)).add(templateInfo);
+ } else if (configName.equals("category")) { //$NON-NLS-1$
+ String id = config.getAttribute("id"); //$NON-NLS-1$
+ if (!id.contains(".")) //$NON-NLS-1$
+ id = pluginId + "." + id; //$NON-NLS-1$
+ String label = config.getAttribute("label"); //$NON-NLS-1$
+
+ IConfigurationElement[] parentCategoryConfigs = config.getChildren("parentCategory"); //$NON-NLS-1$
+ List<String> parentCategoryIds = new ArrayList<String>();
+ for (IConfigurationElement parentCategoryConfig : parentCategoryConfigs)
+ parentCategoryIds.add(parentCategoryConfig.getAttribute("id")); //$NON-NLS-1$
- IConfigurationElement[] toolChainConfigs = config.getChildren(TemplateEngineHelper.TOOL_CHAIN);
- Set<String> toolChainIdSet = new LinkedHashSet<String>();
- for (int k=0; k < toolChainConfigs.length; k++) {
- toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID));
- }
-
- TemplateInfo templateInfo = new TemplateInfo(templateId, projectType, filterPattern, location,
- pluginId, toolChainIdSet,
- extraPagesProvider, isCategory);
- if (!templateInfoMap.containsKey(projectType)) {
- templateInfoMap.put(projectType, new ArrayList<TemplateInfo>());
+ categoryMap.put(id, new TemplateCategory(id, label, parentCategoryIds));
}
- (templateInfoMap.get(projectType)).add(templateInfo);
}
}
// Check for tool Chains added to the templates outside template info definition
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java
new file mode 100644
index 0000000000..1e172ca620
--- /dev/null
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine2.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Doug Schaefer - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.templateengine;
+
+/**
+ * @author Doug Schaefer
+ * @since 5.4
+ */
+public class TemplateEngine2 extends TemplateEngine {
+
+ /**
+ * Project type for new templates. Default if not set in extension.
+ */
+ public static final String NEW_TEMPLATE = "newTemplate"; //$NON-NLS-1$
+
+ public static TemplateEngine2 getDefault() {
+ return (TemplateEngine2)TemplateEngine.getDefault();
+ }
+
+ public TemplateCategory getCategory(String id) {
+ return categoryMap.get(id);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java
new file mode 100644
index 0000000000..478e0cf261
--- /dev/null
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo2.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Doug Schaefer - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.templateengine;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Template info extended to include new stuff for new new project wizard UI.
+ *
+ * @author Doug Schaefer
+ * @since 5.4
+ */
+public class TemplateInfo2 extends TemplateInfo {
+
+ private List<String> parentCategoryIds;
+
+ public TemplateInfo2(String templateId, String projectTypeId, String filterPattern,
+ String templatePath, String pluginId, Set<String> toolChainIdSet,
+ Object extraPagesProvider, boolean isCategory, List<String> parentCategoryIds) {
+ super(templateId, projectTypeId, filterPattern, templatePath, pluginId, toolChainIdSet,
+ extraPagesProvider, isCategory);
+ this.parentCategoryIds = parentCategoryIds;
+ }
+
+ public List<String> getParentCategoryIds() {
+ return parentCategoryIds;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui.tests/plugin.xml b/core/org.eclipse.cdt.ui.tests/plugin.xml
index b281c1f38c..0d2e6d193f 100644
--- a/core/org.eclipse.cdt.ui.tests/plugin.xml
+++ b/core/org.eclipse.cdt.ui.tests/plugin.xml
@@ -113,12 +113,22 @@
location="resources/projectTemplates/testExtraPages/template.xml"
pagesAfterTemplateSelectionProvider="org.eclipse.cdt.ui.tests.templateengine.TestExtraPagesProvider"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
+ <parentCategory
+ id="org.eclipse.cdt.ui.tests.uiTests">
+ </parentCategory>
</template>
<template
id="org.eclipse.cdt.ui.tests.testWidgets"
location="resources/projectTemplates/testWidgets/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
+ <parentCategory
+ id="org.eclipse.cdt.ui.tests.uiTests">
+ </parentCategory>
</template>
+ <category
+ id="org.eclipse.cdt.ui.tests.uiTests"
+ label="UI Tests">
+ </category>
</extension>
diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index b1c9591dfa..87d10a5f7e 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -630,4 +630,4 @@ RefreshExclusionContributor.name = Resources
extension-point.name = Refresh Exclusion Contributor
# New New Project Wizard
-newProjectWizard.name = C/C++ Project (new)
+newProjectWizard.name = C/C++ Project (prototype)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/TemplateSelectionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/TemplateSelectionPage.java
index 7ca68f7589..049d2de04f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/TemplateSelectionPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/TemplateSelectionPage.java
@@ -11,22 +11,77 @@
package org.eclipse.cdt.ui.wizards;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.List;
+import org.eclipse.cdt.core.templateengine.TemplateCategory;
+import org.eclipse.cdt.core.templateengine.TemplateEngine2;
+import org.eclipse.cdt.core.templateengine.TemplateInfo2;
+import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.templateengine.Template;
import org.eclipse.cdt.ui.templateengine.TemplateEngineUI;
/**
- * @author Dad
+ * @author Doug Schaefer
* @since 5.4
*/
public class TemplateSelectionPage extends WizardPage {
+ private static class Node {
+ private final Object object;
+ private final Node parent;
+ private final List<Node> children = new LinkedList<Node>();
+
+ public Node(Node parent, Object object) {
+ this.parent = parent;
+ this.object = object;
+
+ if (parent != null)
+ parent.addChild(this);
+ }
+
+ private void addChild(Node child) {
+ children.add(child);
+ }
+
+ public Node getChild(Object child) {
+ for (Node childNode : children)
+ if (childNode.getObject().equals(child))
+ return childNode;
+ return null;
+ }
+
+ public Object getObject() {
+ return object;
+ }
+
+ public Node getParent() {
+ return parent;
+ }
+
+ public List<Node> getChildren() {
+ return children;
+ }
+ }
+
+ private final Node tree = new Node(null, null);
+ private final TemplateEngine2 coreEngine = TemplateEngine2.getDefault();
+ private final TemplateEngineUI uiEngine = TemplateEngineUI.getDefault();
+
public TemplateSelectionPage() {
super("templateSelection"); //$NON-NLS-1$
}
@@ -36,13 +91,82 @@ public class TemplateSelectionPage extends WizardPage {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout(1, false));
- List templateList = new List(comp, SWT.BORDER);
- templateList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Template[] templates = TemplateEngineUI.getDefault().getTemplates();
- for (Template template : templates) {
- templateList.add(template.getLabel());
- }
+ TreeViewer templateTree = new TreeViewer(comp);
+ templateTree.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ templateTree.setContentProvider(new ITreeContentProvider() {
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ if (element instanceof Node)
+ return !((Node)element).getChildren().isEmpty();
+ return false;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof Node)
+ return ((Node)element).getParent();
+ return null;
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof Node)
+ return ((Node)inputElement).getChildren().toArray();
+ return null;
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof Node)
+ return ((Node)parentElement).getChildren().toArray();
+ return null;
+ }
+ });
+ templateTree.setLabelProvider(new ILabelProvider() {
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof Node) {
+ Object object = ((Node)element).getObject();
+ if (object instanceof TemplateCategory)
+ return ((TemplateCategory)object).getLabel();
+ else if (object instanceof Template)
+ return ((Template)object).getLabel();
+ }
+ return element.toString();
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+ });
+ buildTree();
+ templateTree.setInput(tree);
setControl(comp);
}
@@ -52,4 +176,68 @@ public class TemplateSelectionPage extends WizardPage {
return true;
}
+ private void buildTree() {
+ Template[] templates = uiEngine.getTemplates();
+ for (Template template : templates) {
+ List<String> parentCategoryIds = ((TemplateInfo2)template.getTemplateInfo()).getParentCategoryIds();
+ boolean inTree = false;
+ if (!parentCategoryIds.isEmpty()) {
+ for (String parentCategoryId : parentCategoryIds) {
+ List<Node> parents = getParents(parentCategoryId);
+ if (!parents.isEmpty()) {
+ for (Node parent : parents)
+ new Node(parent, template);
+ inTree = true;
+ }
+ }
+ }
+
+ if (!inTree) {
+ // no parents
+ new Node(tree, template);
+ }
+ }
+ }
+
+ private List<Node> getParents(String parentCategoryId) {
+ List<Node> nodes = new LinkedList<Node>();
+
+ TemplateCategory category = coreEngine.getCategory(parentCategoryId);
+ if (category == null) {
+ // undefined, log it
+ CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Undefined parent category " + parentCategoryId)); //$NON-NLS-1$
+ return nodes;
+ }
+
+ // Hook me up to my parents
+ List<String> parentCategoryIds = category.getParentCategoryIds();
+ boolean inTree = false;
+ if (!parentCategoryIds.isEmpty()) {
+ for (String myParentId : parentCategoryIds) {
+ List<Node> parents = getParents(myParentId);
+ if (!parents.isEmpty()) {
+ for (Node parent : parents) {
+ Node node = parent.getChild(category);
+ if (node == null)
+ nodes.add(new Node(parent, category));
+ else
+ nodes.add(node);
+ }
+ inTree = true;
+ }
+ }
+ }
+
+ if (!inTree) {
+ // parents not found, I'm an orphan
+ Node node = tree.getChild(category);
+ if (node == null)
+ nodes.add(new Node(tree, category));
+ else
+ nodes.add(node);
+ }
+
+ return nodes;
+ }
+
}

Back to the top