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/templateengine
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/templateengine')
-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
4 files changed, 76 insertions, 13 deletions
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