1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-21 23:33:57 +02:00

Add real categories for templates. Organize selection in tree.

This commit is contained in:
Doug Schaefer 2012-01-27 13:40:32 -05:00
parent f13bdf3b33
commit 6fcb52fe97
11 changed files with 720 additions and 277 deletions

View file

@ -6741,45 +6741,81 @@
<extension <extension
point="org.eclipse.cdt.core.templates"> point="org.eclipse.cdt.core.templates">
<template <template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.AppendToMBSStringOptionValue"
filterPattern=".*AppendToMBSStringOptionValue" filterPattern=".*AppendToMBSStringOptionValue"
id="org.eclipse.cdt.managedbuilder.core.tests.templates.AppendToMBSStringOptionValue"
location="testdata/AppendToMBSStringOptionValue.xml" 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 <template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.AppendToMBSStringListOptionValues"
filterPattern=".*AppendToMBSStringListOptionValues" filterPattern=".*AppendToMBSStringListOptionValues"
id="org.eclipse.cdt.managedbuilder.core.tests.templates.AppendToMBSStringListOptionValues"
location="testdata/AppendToMBSStringListOptionValues.xml" 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 <template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.CreateIncludeFolder"
filterPattern=".*CreateIncludeFolder" filterPattern=".*CreateIncludeFolder"
id="org.eclipse.cdt.managedbuilder.core.tests.templates.CreateIncludeFolder"
location="testdata/CreateIncludeFolder.xml" 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 <template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.ExcludeResources"
filterPattern=".*ExcludeResources" filterPattern=".*ExcludeResources"
id="org.eclipse.cdt.managedbuilder.core.tests.templates.ExcludeResources"
location="testdata/ExcludeResources.xml" 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 <template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.NewManagedProject"
filterPattern=".*NewManagedProject" filterPattern=".*NewManagedProject"
id="org.eclipse.cdt.managedbuilder.core.tests.templates.NewManagedProject"
location="testdata/NewManagedProject.xml" 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 <template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSBooleanOptionValue"
filterPattern=".*SetMBSBooleanOptionValue" filterPattern=".*SetMBSBooleanOptionValue"
id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSBooleanOptionValue"
location="testdata/SetMBSBooleanOptionValue.xml" 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 <template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSStringOptionValue"
filterPattern=".*SetMBSStringOptionValue" filterPattern=".*SetMBSStringOptionValue"
id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSStringOptionValue"
location="testdata/SetMBSStringOptionValue.xml" 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 <template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSStringListOptionValues"
filterPattern=".*SetMBSStringListOptionValues" filterPattern=".*SetMBSStringListOptionValues"
id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSStringListOptionValues"
location="testdata/SetMBSStringListOptionValues.xml" 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> </extension>
<!-- 4.0 tests --> <!-- 4.0 tests -->

View file

@ -10,8 +10,8 @@
############################################################################### ###############################################################################
#Template Default Values #Template Default Values
MakefileHelloWorld.CCtemplate.label=Hello World C++ Project MakefileHelloWorld.CCtemplate.label=Hello World C++ Makefile Project
MakefileHelloWorld.CCtemplate.description=A Hello World C++ Project MakefileHelloWorld.CCtemplate.description=A Hello World C++ Makefile Project
MakefileHelloWorld.basics.label=Basic Settings MakefileHelloWorld.basics.label=Basic Settings
MakefileHelloWorld.basics.description=Basic properties of a project MakefileHelloWorld.basics.description=Basic properties of a project
MakefileHelloWorld.author.label=Author MakefileHelloWorld.author.label=Author

View file

@ -82,6 +82,9 @@
isCategory="true" isCategory="true"
location="resources/templateengine/AddFile.xml" location="resources/templateengine/AddFile.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>
<template <template
id="org.eclipse.cdt.core.tests.templates.AddFiles" id="org.eclipse.cdt.core.tests.templates.AddFiles"
@ -90,38 +93,68 @@
projectType="org.eclipse.cdt.core.tests.projectType"> projectType="org.eclipse.cdt.core.tests.projectType">
<toolChain id="org.eclipse.cdt.core.tests.toolChain1"/> <toolChain id="org.eclipse.cdt.core.tests.toolChain1"/>
<toolChain id="org.eclipse.cdt.core.tests.toolChain2"/> <toolChain id="org.eclipse.cdt.core.tests.toolChain2"/>
<parentCategory
id="org.eclipse.cdt.core.tests.coreTests">
</parentCategory>
</template> </template>
<template <template
id="org.eclipse.cdt.core.tests.templates.AddLink" id="org.eclipse.cdt.core.tests.templates.AddLink"
filterPattern=".*AddLink" filterPattern=".*AddLink"
location="resources/templateengine/AddLink.xml" location="resources/templateengine/AddLink.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>
<template <template
id="org.eclipse.cdt.core.tests.templates.Append"
filterPattern=".*Append" filterPattern=".*Append"
id="org.eclipse.cdt.core.tests.templates.Append"
location="resources/templateengine/Append.xml" 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 <template
id="org.eclipse.cdt.core.tests.templates.AppendCreate"
filterPattern=".*AppendCreate" filterPattern=".*AppendCreate"
id="org.eclipse.cdt.core.tests.templates.AppendCreate"
location="resources/templateengine/AppendCreate.xml" 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 <template
id="org.eclipse.cdt.core.tests.templates.Copy"
filterPattern=".*Copy" filterPattern=".*Copy"
id="org.eclipse.cdt.core.tests.templates.Copy"
location="resources/templateengine/Copy.xml" 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 <template
id="org.eclipse.cdt.core.tests.templates.CreateResourceIdentifier"
filterPattern=".*CreateResourceIdentifier" filterPattern=".*CreateResourceIdentifier"
id="org.eclipse.cdt.core.tests.templates.CreateResourceIdentifier"
location="resources/templateengine/CreateResourceIdentifier.xml" 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 <template
id="org.eclipse.cdt.core.tests.templates.CreateSourceFolder"
filterPattern=".*CreateSourceFolder" filterPattern=".*CreateSourceFolder"
id="org.eclipse.cdt.core.tests.templates.CreateSourceFolder"
location="resources/templateengine/CreateSourceFolder.xml" 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>
<extension <extension
point="org.eclipse.cdt.core.templateAssociations"> point="org.eclipse.cdt.core.templateAssociations">

View file

@ -1,201 +1,245 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE --> <!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.core"> <schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation> <annotation>
<appInfo> <appInfo>
<meta.schema plugin="org.eclipse.cdt.core" id="templates" name="Template Extension point"/> <meta.schema plugin="org.eclipse.cdt.core" id="templates" name="Template Extension point"/>
</appInfo> </appInfo>
<documentation> <documentation>
This templates extension point facilitates the users to contribute their Template XMLs to the Template Engine plug-in. This templates extension point facilitates the users to contribute their Template XMLs to the Template Engine plug-in.
</documentation> </documentation>
</annotation> </annotation>
<element name="extension"> <element name="extension">
<annotation> <annotation>
<documentation> <appInfo>
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. <meta.element />
</appInfo>
</documentation> <documentation>
</annotation> 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.
<complexType> </documentation>
<sequence> </annotation>
<element ref="template" minOccurs="1" maxOccurs="unbounded"/> <complexType>
</sequence> <sequence>
<attribute name="point" type="string" use="required"> <element ref="template" minOccurs="1" maxOccurs="unbounded"/>
<annotation> <element ref="category" minOccurs="0" maxOccurs="unbounded"/>
<documentation> </sequence>
<attribute name="point" type="string" use="required">
</documentation> <annotation>
</annotation> <documentation>
</attribute>
<attribute name="id" type="string"> </documentation>
<annotation> </annotation>
<documentation> </attribute>
Id for the extension in the extender plugin. <attribute name="id" type="string">
</documentation> <annotation>
</annotation> <documentation>
</attribute> Id for the extension in the extender plugin.
<attribute name="name" type="string"> </documentation>
<annotation> </annotation>
<documentation> </attribute>
Optional name attribute. <attribute name="name" type="string">
</documentation> <annotation>
<appInfo> <documentation>
<meta.attribute translatable="true"/> Optional name attribute.
</appInfo> </documentation>
</annotation> <appInfo>
</attribute> <meta.attribute translatable="true"/>
</complexType> </appInfo>
</element> </annotation>
</attribute>
<element name="template"> </complexType>
<annotation> </element>
<documentation>
By adding the templates extension point the users can contribute their Template XMLs to the Template Engine plugin. <element name="template">
</documentation> <annotation>
</annotation> <documentation>
<complexType> By adding the templates extension point the users can contribute their Template XMLs to the Template Engine plugin.
<sequence> </documentation>
<element ref="toolChain" minOccurs="0" maxOccurs="unbounded"/> </annotation>
</sequence> <complexType>
<attribute name="id" type="string" use="required"> <sequence>
<annotation> <element ref="toolChain" minOccurs="0" maxOccurs="unbounded"/>
<documentation> <element ref="parentCategory" minOccurs="0" maxOccurs="unbounded"/>
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). </sequence>
</documentation> <attribute name="id" type="string" use="required">
</annotation> <annotation>
</attribute> <documentation>
<attribute name="location" type="string" use="required"> 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).
<annotation> </documentation>
<documentation> </annotation>
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. </attribute>
</documentation> <attribute name="location" type="string" use="required">
<appInfo> <annotation>
<meta.attribute kind="resource"/> <documentation>
</appInfo> 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.
</annotation> </documentation>
</attribute> <appInfo>
<attribute name="projectType" type="string" use="required"> <meta.attribute kind="resource"/>
<annotation> </appInfo>
<documentation> </annotation>
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. </attribute>
This attribute is mandatory. CDT pre-defines the following values of the build artifact type property: <attribute name="projectType" type="string">
&lt;ul&gt; <annotation>
&lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.exe&quot; - to represent executable <documentation>
&lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.staticLib&quot; - to represent static library 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.
&lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.sharedLib&quot; - to represent shared library This attribute is mandatory. CDT pre-defines the following values of the build artifact type property:
&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;
&lt;/ul&gt; &lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.exe&quot; - to represent executable
</documentation> &lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.staticLib&quot; - to represent static library
</annotation> &lt;li&gt;&quot;org.eclipse.cdt.build.core.buildArtefactType.sharedLib&quot; - to represent shared library
</attribute> &lt;li&gt;ISVs can define their own custom build artifact values by contributing to the org.eclipse.cdt.managedbuilder.core.buildProperties extension point.
<attribute name="isCategory" type="boolean"> &lt;/ul&gt;
<annotation> It&apos;s no longer manditory since templates are no longer organized by project type. Template catogories replace that functionality.
<documentation> </documentation>
If true this template contribution should appear as a folder. Defaults to false. </annotation>
</documentation> </attribute>
</annotation> <attribute name="isCategory" type="boolean">
</attribute> <annotation>
<attribute name="filterPattern" type="string"> <documentation>
<annotation> If true this template contribution should appear as a folder. Defaults to false.
<documentation> </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. </annotation>
</documentation> </attribute>
</annotation> <attribute name="filterPattern" type="string">
</attribute> <annotation>
<attribute name="pagesAfterTemplateSelectionProvider" type="string"> <documentation>
<annotation> 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> </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(). </annotation>
</documentation> </attribute>
<appInfo> <attribute name="pagesAfterTemplateSelectionProvider" type="string">
<meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.templateengine.IPagesAfterTemplateSelectionProvider"/> <annotation>
</appInfo> <documentation>
</annotation> A class that implements org.eclipse.cdt.templateengine.IPagesAfterTemplateSelectionProvider interface to create pages that will be appended to the pages returned from TemplatesChoiceWizard.getPagesAfterTemplateSelection().
</attribute> </documentation>
</complexType> <appInfo>
</element> <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.templateengine.IPagesAfterTemplateSelectionProvider"/>
</appInfo>
<element name="toolChain"> </annotation>
<annotation> </attribute>
<documentation> </complexType>
This element is used to reference an existing toolchain by its unique identifier. </element>
</documentation>
</annotation> <element name="toolChain">
<complexType> <annotation>
<attribute name="id" type="string" use="required"> <documentation>
<annotation> This element is used to reference an existing toolchain by its unique identifier.
<documentation> </documentation>
The unique identifier of a toolchain contributed to the org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point. </annotation>
</documentation> <complexType>
</annotation> <attribute name="id" type="string" use="required">
</attribute> <annotation>
</complexType> <documentation>
</element> The unique identifier of a toolchain contributed to the org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point.
</documentation>
<annotation> </annotation>
<appInfo> </attribute>
<meta.section type="since"/> </complexType>
</appInfo> </element>
<documentation>
This extension point was added in CDT 4.0 <element name="category">
</documentation> <annotation>
</annotation> <documentation>
Used to arrange templates in a hierarchy in the UI.
<annotation> </documentation>
<appInfo> </annotation>
<meta.section type="examples"/> <complexType>
</appInfo> <sequence>
<documentation> <element ref="parentCategory" minOccurs="0" maxOccurs="unbounded"/>
The following is an example of the extension point usage: </sequence>
&lt;p&gt; <attribute name="id" type="string" use="required">
&lt;pre&gt; <annotation>
&lt;extension point=&quot;org.eclipse.cdt.core.templates&quot;&gt; <documentation>
&lt;template
id=&quot;org.foobar.templates.MyExampleTemplate&quot; </documentation>
location=&quot;templates/MyExampleTemplate/template.xml&quot; </annotation>
projectType=&quot;org.eclipse.cdt.build.core.buildArtefactType.exe&quot; </attribute>
filterPattern=&quot;.*&quot;&gt; <attribute name="label" type="string" use="required">
&lt;/template&gt; <annotation>
&lt;/extension&gt; <documentation>
&lt;/pre&gt;
</documentation>
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; <appInfo>
</documentation> <meta.attribute translatable="true"/>
</annotation> </appInfo>
</annotation>
<annotation> </attribute>
<appInfo> </complexType>
<meta.section type="apiInfo"/> </element>
</appInfo>
<documentation> <element name="parentCategory">
<annotation>
</documentation> <documentation>
</annotation> id of parent category.
</documentation>
<annotation> </annotation>
<appInfo> <complexType>
<meta.section type="implementation"/> <attribute name="id" type="string" use="required">
</appInfo> <annotation>
<documentation> <documentation>
An implementation of this extension point is supplied in &lt;samp&gt;org.eclipse.cdt.templateengine&lt;/samp&gt;
</documentation> </documentation>
</annotation> </annotation>
</attribute>
<annotation> </complexType>
<appInfo> </element>
<meta.section type="copyright"/>
</appInfo>
<documentation> <annotation>
Copyright (c) 2007 Symbian Software Limited and others. <appInfo>
All rights reserved. This program and the accompanying materials <meta.section type="since"/>
are made available under the terms of the Eclipse Public License v1.0 </appInfo>
which accompanies this distribution, and is available at <documentation>
http://www.eclipse.org/legal/epl-v10.html This extension point was added in CDT 4.0
</documentation>
Contributors: </annotation>
Symbian - Initial API and implementation
</documentation> <annotation>
</annotation> <appInfo>
<meta.section type="examples"/>
</schema> </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>

View file

@ -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;
}
}

View file

@ -53,13 +53,15 @@ public class TemplateEngine {
/** /**
* This is a Map <WizardID, TemplateInfo>. * 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. * TemplateEngine constructor, create and initialise SharedDefaults.
*/ */
private TemplateEngine() { TemplateEngine() {
templateInfoMap = new LinkedHashMap<String, List<TemplateInfo>>();
initializeTemplateInfoMap(); initializeTemplateInfoMap();
} }
@ -190,7 +192,7 @@ public class TemplateEngine {
*/ */
public static TemplateEngine getDefault() { public static TemplateEngine getDefault() {
if(TEMPLATE_ENGINE==null) { if(TEMPLATE_ENGINE==null) {
TEMPLATE_ENGINE = new TemplateEngine(); TEMPLATE_ENGINE = new TemplateEngine2();
} }
return TEMPLATE_ENGINE; return TEMPLATE_ENGINE;
} }
@ -201,48 +203,62 @@ public class TemplateEngine {
* extension point "templates" * extension point "templates"
*/ */
private void initializeTemplateInfoMap() { 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(); IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(TEMPLATES_EXTENSION_ID).getExtensions();
for(int i=0; i<extensions.length; i++) { for(int i=0; i<extensions.length; i++) {
IExtension extension = extensions[i]; IExtension extension = extensions[i];
IConfigurationElement[] configElements = extension.getConfigurationElements(); 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++) { for(int j=0; j<configElements.length; j++) {
Object /*IPagesAfterTemplateSelectionProvider*/ extraPagesProvider = null;
IConfigurationElement config = configElements[j]; IConfigurationElement config = configElements[j];
templateId = config.getAttribute(TemplateEngineHelper.ID); String configName = config.getName();
location = config.getAttribute(TemplateEngineHelper.LOCATION); if (configName.equals("template")) { //$NON-NLS-1$
projectType = config.getAttribute(TemplateEngineHelper.PROJECT_TYPE); Object /*IPagesAfterTemplateSelectionProvider*/ extraPagesProvider = null;
filterPattern = config.getAttribute(TemplateEngineHelper.FILTER_PATTERN); String templateId = config.getAttribute(TemplateEngineHelper.ID);
isCategory = Boolean.valueOf(config.getAttribute(TemplateEngineHelper.IS_CATEGORY)).booleanValue(); String location = config.getAttribute(TemplateEngineHelper.LOCATION);
String providerAttribute = config.getAttribute(TemplateEngineHelper.EXTRA_PAGES_PROVIDER); String projectType = config.getAttribute(TemplateEngineHelper.PROJECT_TYPE);
if (providerAttribute != null) { if (projectType == null || projectType.isEmpty())
try { projectType = TemplateEngine2.NEW_TEMPLATE;
extraPagesProvider = config.createExecutableExtension(TemplateEngineHelper.EXTRA_PAGES_PROVIDER); String filterPattern = config.getAttribute(TemplateEngineHelper.FILTER_PATTERN);
} catch (CoreException e) { boolean isCategory = Boolean.valueOf(config.getAttribute(TemplateEngineHelper.IS_CATEGORY)).booleanValue();
CCorePlugin.log(CCorePlugin.createStatus("Unable to create extra pages for "+providerAttribute,e)); //$NON-NLS-1$ 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); categoryMap.put(id, new TemplateCategory(id, label, parentCategoryIds));
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>());
}
(templateInfoMap.get(projectType)).add(templateInfo);
} }
} }
// Check for tool Chains added to the templates outside template info definition // Check for tool Chains added to the templates outside template info definition

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -113,12 +113,22 @@
location="resources/projectTemplates/testExtraPages/template.xml" location="resources/projectTemplates/testExtraPages/template.xml"
pagesAfterTemplateSelectionProvider="org.eclipse.cdt.ui.tests.templateengine.TestExtraPagesProvider" pagesAfterTemplateSelectionProvider="org.eclipse.cdt.ui.tests.templateengine.TestExtraPagesProvider"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe"> projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
<parentCategory
id="org.eclipse.cdt.ui.tests.uiTests">
</parentCategory>
</template> </template>
<template <template
id="org.eclipse.cdt.ui.tests.testWidgets" id="org.eclipse.cdt.ui.tests.testWidgets"
location="resources/projectTemplates/testWidgets/template.xml" location="resources/projectTemplates/testWidgets/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe"> projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
<parentCategory
id="org.eclipse.cdt.ui.tests.uiTests">
</parentCategory>
</template> </template>
<category
id="org.eclipse.cdt.ui.tests.uiTests"
label="UI Tests">
</category>
</extension> </extension>

View file

@ -630,4 +630,4 @@ RefreshExclusionContributor.name = Resources
extension-point.name = Refresh Exclusion Contributor extension-point.name = Refresh Exclusion Contributor
# New New Project Wizard # New New Project Wizard
newProjectWizard.name = C/C++ Project (new) newProjectWizard.name = C/C++ Project (prototype)

View file

@ -11,22 +11,77 @@
package org.eclipse.cdt.ui.wizards; 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.jface.wizard.WizardPage;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; 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.Template;
import org.eclipse.cdt.ui.templateengine.TemplateEngineUI; import org.eclipse.cdt.ui.templateengine.TemplateEngineUI;
/** /**
* @author Dad * @author Doug Schaefer
* @since 5.4 * @since 5.4
*/ */
public class TemplateSelectionPage extends WizardPage { 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() { public TemplateSelectionPage() {
super("templateSelection"); //$NON-NLS-1$ super("templateSelection"); //$NON-NLS-1$
} }
@ -36,13 +91,82 @@ public class TemplateSelectionPage extends WizardPage {
Composite comp = new Composite(parent, SWT.NONE); Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout(1, false)); comp.setLayout(new GridLayout(1, false));
List templateList = new List(comp, SWT.BORDER); TreeViewer templateTree = new TreeViewer(comp);
templateList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); templateTree.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
templateTree.setContentProvider(new ITreeContentProvider() {
Template[] templates = TemplateEngineUI.getDefault().getTemplates(); @Override
for (Template template : templates) { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
templateList.add(template.getLabel()); }
}
@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); setControl(comp);
} }
@ -52,4 +176,68 @@ public class TemplateSelectionPage extends WizardPage {
return true; 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;
}
} }