Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Sennikovsky2007-05-10 16:03:53 +0000
committerMikhail Sennikovsky2007-05-10 16:03:53 +0000
commit13968f31020951b24df341f1ef3eba96daeece15 (patch)
tree2ae837384fc1d3e1c3eec65840fafd146717bc9d /core/org.eclipse.cdt.core
parent463823931b9706528da4ab8147d97d2dc7e1a616 (diff)
downloadorg.eclipse.cdt-13968f31020951b24df341f1ef3eba96daeece15.tar.gz
org.eclipse.cdt-13968f31020951b24df341f1ef3eba96daeece15.tar.xz
org.eclipse.cdt-13968f31020951b24df341f1ef3eba96daeece15.zip
patch from Bala Torati with small modifications
1. Fix for [Bug 184449] [Template Engine] It should be possible to press "Finish" on the first wizard page for templates having default values assigned 2. Fix for [Bug 184593] [Template Engine] Need a way to add tool-chain associations to existing templates 3. Fix for [Bug 184455] [Template Engine] NPE in template engine tests
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml1
-rw-r--r--core/org.eclipse.cdt.core/schema/templateAssociations.exsd129
-rw-r--r--core/org.eclipse.cdt.core/schema/templates.exsd7
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java20
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java48
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo.java16
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/TemplateProcessHandler.java5
7 files changed, 213 insertions, 13 deletions
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index 038e70b319d..d39a2d8135f 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -629,6 +629,7 @@
<extension-point id="templates" name="Templates Extension point"
schema="schema/templates.exsd"/>
<extension-point id="templateProcessTypes" name="Process Types Extension point" schema="schema/templateProcessTypes.exsd"/>
+ <extension-point id="templateAssociations" name="Template Associations" schema="schema/templateAssociations.exsd"/>
<extension
point="org.eclipse.cdt.core.templateProcessTypes">
diff --git a/core/org.eclipse.cdt.core/schema/templateAssociations.exsd b/core/org.eclipse.cdt.core/schema/templateAssociations.exsd
new file mode 100644
index 00000000000..4130eedb490
--- /dev/null
+++ b/core/org.eclipse.cdt.core/schema/templateAssociations.exsd
@@ -0,0 +1,129 @@
+<?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="templateAssociations" name="Template Associations"/>
+ </appInfo>
+ <documentation>
+ This extension point facilitates adding new toolchains generated from a different plugin to already defined template without modifying template definition.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <documentation>
+ Extension point added to Template Engine plugin. Any plugin, which intends to contribute XML templates to Temaplate Engine has to extend this extension point, and add 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>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="toolChain">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="template">
+ <complexType>
+ <sequence>
+ <element ref="toolChain" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <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>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </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/schema/templates.exsd b/core/org.eclipse.cdt.core/schema/templates.exsd
index eee1c106792..b2a62c32360 100644
--- a/core/org.eclipse.cdt.core/schema/templates.exsd
+++ b/core/org.eclipse.cdt.core/schema/templates.exsd
@@ -108,6 +108,13 @@ This is an optional attribute.
</documentation>
</annotation>
</attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java
index 5e28f4ddc9b..9de6efd5fce 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java
@@ -43,6 +43,7 @@ public class TemplateCore {
private static final String DESCRIPTION = "description"; //$NON-NLS-1$
private static final String LABEL = "label"; //$NON-NLS-1$
private static final String ID = "id"; //$NON-NLS-1$
+ private static final String TYPE = "type"; //$NON-NLS-1$
private static Map/*<TemplateInfo, Template>*/ templateCache = new HashMap/*<TemplateInfo, Template>*/();
@@ -60,6 +61,7 @@ public class TemplateCore {
private String description;
private String label;
private String templateId;
+ private String templateType;
private boolean fireDirtyEvents;
/**
@@ -91,11 +93,9 @@ public class TemplateCore {
*/
public Set/*<String>*/ getAllMissingMacrosInProcesses() {
Set/*<String>*/ set = new TreeSet/*<String>*/(allMacrosInProcesses);
- if (set != null) {
- for (Iterator iter = set.iterator(); iter.hasNext();) {
- if (valueStore.get(iter.next()) != null) {
- iter.remove();
- }
+ for (Iterator iter = set.iterator(); iter.hasNext();) {
+ if (valueStore.get(iter.next()) != null) {
+ iter.remove();
}
}
return set;
@@ -155,6 +155,16 @@ public class TemplateCore {
}
/**
+ * @return String, which contains the id of the template
+ */
+ public String getTemplateType() {
+ if (templateType == null) {
+ templateType = templateDescriptor.getRootElement().getAttribute(TYPE).trim();
+ }
+ return templateType;
+ }
+
+ /**
* @return String, which contains the Label
*/
public String getLabel() {
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 dea101fe822..a02609646b7 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
@@ -13,6 +13,7 @@ package org.eclipse.cdt.core.templateengine;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -40,11 +41,17 @@ import org.w3c.dom.NodeList;
public class TemplateEngine {
public static String TEMPLATES_EXTENSION_ID = CCorePlugin.PLUGIN_ID + ".templates"; //$NON-NLS-1$
+ public static String TEMPLATE_ASSOCIATIONS_EXTENSION_ID = CCorePlugin.PLUGIN_ID + ".templateAssociations"; //$NON-NLS-1$
/**
* static reference to the Singleton TemplateEngine instance.
*/
- private static TemplateEngine TEMPLATE_ENGINE = new TemplateEngine();
+ private static TemplateEngine TEMPLATE_ENGINE;
+
+ static {
+ TEMPLATE_ENGINE = new TemplateEngine();
+ TEMPLATE_ENGINE.initializeTemplateInfoMap();
+ }
/**
* This is a Map <WizardID, TemplateInfo>.
@@ -56,7 +63,6 @@ public class TemplateEngine {
*/
private TemplateEngine() {
templateInfoMap = new HashMap/*<String, List<TemplateInfo>>*/();
- initializeTemplateInfoMap();
}
/**
@@ -190,6 +196,7 @@ public class TemplateEngine {
* extension point "templates"
*/
private void initializeTemplateInfoMap() {
+ String templateId = null;
String location = null;
String pluginId = null;
String projectType = null;
@@ -205,6 +212,7 @@ public class TemplateEngine {
pluginId = extension.getNamespaceIdentifier(); // Plugin-id of the extending plugin.
for(int j=0; j<configElements.length; j++) {
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);
@@ -218,7 +226,7 @@ public class TemplateEngine {
toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID));
}
- TemplateInfo templateInfo = new TemplateInfo(projectType, filterPattern, location,
+ TemplateInfo templateInfo = new TemplateInfo(templateId, projectType, filterPattern, location,
pluginId, toolChainIdSet,
usage, extraPagesProvider, isCategory);
if (!templateInfoMap.containsKey(projectType)) {
@@ -227,8 +235,42 @@ public class TemplateEngine {
((List/*<TemplateInfo>*/)templateInfoMap.get(projectType)).add(templateInfo);
}
}
+ // Check for tool Chains added to the templates outside template info definition
+ addToolChainsToTemplates();
}
+ private void addToolChainsToTemplates() {
+ String templateId = null;
+ TemplateCore[] templates = getTemplates();
+
+ IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(TEMPLATE_ASSOCIATIONS_EXTENSION_ID).getExtensions();
+ for(int i=0; i<extensions.length; i++) {
+ IExtension extension = extensions[i];
+ IConfigurationElement[] configElements = extension.getConfigurationElements();
+ for(int j=0; j<configElements.length; j++) {
+ IConfigurationElement config = configElements[j];
+ templateId = config.getAttribute(TemplateEngineHelper.ID);
+
+ IConfigurationElement[] toolChainConfigs = config.getChildren(TemplateEngineHelper.TOOL_CHAIN);
+ Set toolChainIdSet = new HashSet();
+ for (int k=0; k < toolChainConfigs.length; k++) {
+ toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID));
+ }
+
+ for (int k=0; k < templates.length; k++) {
+ String id = templates[k].getTemplateInfo().getTemplateId();
+ if (id == null) {
+ id = templates[k].getTemplateId();
+ }
+ if (id != null && id.equals(templateId)) {
+ toolChainIdSet.addAll(Arrays.asList(templates[k].getTemplateInfo().getToolChainIds()));
+ templates[k].getTemplateInfo().setToolChainSet(toolChainIdSet);
+ }
+ }
+ }
+ }
+ }
+
/**
* Gets an array of template info objects matching the criteria passed as params.
*/
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo.java
index 169b708964c..b82121903e1 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo.java
@@ -27,10 +27,12 @@ public class TemplateInfo {
private String pagesProvider;
private boolean isCategory;
private String icon;
+ private String templateId;
- public TemplateInfo(String projectTypeId, String filterPattern, String templatePath,
+ public TemplateInfo(String templateId, String projectTypeId, String filterPattern, String templatePath,
String pluginId, Set toolChainIdSet, String usageDescription,
String pagesProvider, boolean isCategory) {
+ this.templateId = templateId;
this.filterPattern = filterPattern;
this.templatePath = templatePath;
this.pluginId = pluginId;
@@ -50,6 +52,14 @@ public class TemplateInfo {
}
/**
+ * Returns the Template ID
+ * @return String contains the template id.
+ */
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ /**
* Returns the Template path as String.
* @return String containing the path.
*/
@@ -90,6 +100,10 @@ public class TemplateInfo {
return (String[]) toolChainIdSet.toArray(new String[toolChainIdSet.size()]);
}
+ public void setToolChainSet(Set toolChainIdSet) {
+ this.toolChainIdSet = toolChainIdSet;
+ }
+
/**
* @return the isCategory
*/
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/TemplateProcessHandler.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/TemplateProcessHandler.java
index eab75afe3ca..6aab5776ac3 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/TemplateProcessHandler.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/TemplateProcessHandler.java
@@ -77,13 +77,10 @@ public class TemplateProcessHandler {
* @return
*/
public Set/*<String>*/ getAllMacros() {
- Set/*<String>*/ set = null;
+ Set/*<String>*/ set = new HashSet/*<String>*/();
for (Iterator i = conditionalProcessGroupList.iterator(); i.hasNext();) {
Set/*<String>*/ subSet = ((ConditionalProcessGroup)i.next()).getAllMacros();
if (subSet != null) {
- if (set == null) {
- set = new HashSet/*<String>*/();
- }
set.addAll(subSet);
}
}

Back to the top