Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferguson2007-10-25 14:45:39 +0000
committerAndrew Ferguson2007-10-25 14:45:39 +0000
commit672ce6566777fd2289f315067b542ff89cd2bb76 (patch)
treead23b83b2b603d84aab929b7c131d4a889ee54c1 /core/org.eclipse.cdt.core/templateengine
parente96881fb2ca40e7ce5cd4eaacbf330b425bd4b6a (diff)
downloadorg.eclipse.cdt-672ce6566777fd2289f315067b542ff89cd2bb76.tar.gz
org.eclipse.cdt-672ce6566777fd2289f315067b542ff89cd2bb76.tar.xz
org.eclipse.cdt-672ce6566777fd2289f315067b542ff89cd2bb76.zip
205182: apply fix and add example template
Diffstat (limited to 'core/org.eclipse.cdt.core/templateengine')
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateCore.java2
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngine.java18
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateInfo.java44
3 files changed, 41 insertions, 23 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 6b95af1df96..e4f6bb45aca 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
@@ -77,6 +77,8 @@ public class TemplateCore {
String msg= MessageFormat.format(TemplateEngineMessages.getString("TemplateCore.InitFailed"), new Object[]{templateInfo.getTemplatePath()}); //$NON-NLS-1$
throw new TemplateInitializationException(msg);
}
+ if(descriptorURL==null)
+ throw new TemplateInitializationException("Unable to load project template. Location URL is null for "+templateInfo.getTemplateId()); //$NON-NLS-1$
templateDescriptor = new TemplateDescriptor(descriptorURL, templateInfo.getPluginId());
valueStore = new ValueStore/*<String, String>*/(this);
valueStore.putAll(templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement()));
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 181cdbec2d1..0b7437170d9 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
@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -55,7 +56,7 @@ public class TemplateEngine {
private Map/*<String, List<TemplateInfo>>*/ templateInfoMap;
/**
- * TemplateEngine constructor, create and initialize SharedDefaults.
+ * TemplateEngine constructor, create and initialise SharedDefaults.
*/
private TemplateEngine() {
templateInfoMap = new LinkedHashMap/*<String, List<TemplateInfo>>*/();
@@ -73,7 +74,7 @@ public class TemplateEngine {
try {
tcores.add(TemplateCore.getTemplate(info));
} catch (TemplateInitializationException e) {
- CCorePlugin.log(e);
+ CCorePlugin.log(CCorePlugin.createStatus(e.getMessage(), e));
}
}
return (TemplateCore[]) tcores.toArray(new TemplateCore[tcores.size()]);
@@ -211,7 +212,7 @@ public class TemplateEngine {
String projectType = null;
String filterPattern = null;
boolean isCategory = false;
- String extraPagesProvider = null;
+ Object /*IPagesAfterTemplateSelectionProvider*/ extraPagesProvider = null;
IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(TEMPLATES_EXTENSION_ID).getExtensions();
for(int i=0; i<extensions.length; i++) {
@@ -225,8 +226,15 @@ public class TemplateEngine {
projectType = config.getAttribute(TemplateEngineHelper.PROJECT_TYPE);
filterPattern = config.getAttribute(TemplateEngineHelper.FILTER_PATTERN);
isCategory = Boolean.valueOf(config.getAttribute(TemplateEngineHelper.IS_CATEGORY)).booleanValue();
- extraPagesProvider = config.getAttribute(TemplateEngineHelper.EXTRA_PAGES_PROVIDER);
-
+ 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 toolChainIdSet = new LinkedHashSet();
for (int k=0; k < toolChainConfigs.length; k++) {
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 0552e7ebd73..98d5df7e87c 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
@@ -13,8 +13,6 @@ package org.eclipse.cdt.core.templateengine;
import java.util.List;
import java.util.Set;
-
-
/**
* TemplateInfo class contains the template information like wizard ID, pattern, path and project type.
*/
@@ -24,59 +22,69 @@ public class TemplateInfo {
private String templatePath;
private String pluginId;
private Set toolChainIdSet;
- private String pagesProvider;
+ private Object pagesProvider; /* IPagesAfterTemplateSelectionProvider */
private boolean isCategory;
private String icon;
private String templateId;
private List configs;
+ /**
+ *
+ * @param templateId
+ * @param projectTypeId
+ * @param filterPattern
+ * @param templatePath
+ * @param pluginId
+ * @param toolChainIdSet
+ * @param extraPagesProvider an IPagesAfterTemplateSelectionProvider or null
+ * @param isCategory
+ */
public TemplateInfo(String templateId, String projectTypeId, String filterPattern, String templatePath,
String pluginId, Set toolChainIdSet,
- String pagesProvider, boolean isCategory) {
+ Object extraPagesProvider, boolean isCategory) {
this.templateId = templateId;
this.filterPattern = filterPattern;
this.templatePath = templatePath;
this.pluginId = pluginId;
this.projectTypeId = projectTypeId;
this.toolChainIdSet = toolChainIdSet;
- this.pagesProvider = pagesProvider;
+ this.pagesProvider = extraPagesProvider;
this.isCategory = isCategory;
this.configs = null;
}
/**
- * Returns the Plugin ID
- * @return String contains the plugin id.
+ * @return the plug-in id
*/
public String getPluginId() {
return pluginId;
}
/**
- * Returns the Template ID
- * @return String contains the template id.
+ * @return the template id.
*/
public String getTemplateId() {
return templateId;
}
/**
- * Returns the Template path as String.
- * @return String containing the path.
+ * @return the template path
*/
public String getTemplatePath() {
return templatePath;
}
/**
- * Returns the Filter Pattern.
- * @return String containing the Filter Pattern.
+ * @return the filter Pattern.
*/
public String getFilterPattern() {
return filterPattern;
}
- public String getExtraPagesProvider() {
+ /**
+ * @return an IPagesAfterTemplateSelectionProvider or null
+ */
+ public Object getExtraPagesProvider() {
return pagesProvider;
}
@@ -107,7 +115,7 @@ public class TemplateInfo {
}
/**
- * @return the isCategory
+ * @return whether this template is a category
*/
public boolean isCategory() {
return isCategory;
@@ -135,11 +143,11 @@ public class TemplateInfo {
return false;
}
- /**
- * Return the hashcode of the object.
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
*/
public int hashCode() {
return projectTypeId.hashCode() | templatePath.hashCode() | pluginId.hashCode();
}
-
}

Back to the top