--- a/org.symbian.tools.mtw.ui/schema/projectTemplate.exsd Fri Aug 13 16:28:00 2010 -0700
+++ b/org.symbian.tools.mtw.ui/schema/projectTemplate.exsd Fri Aug 13 17:26:00 2010 -0700
@@ -19,6 +19,7 @@
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="template"/>
+ <element ref="runtime-template"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
@@ -60,6 +61,7 @@
<element ref="description"/>
<element ref="required-facet"/>
<element ref="supported-runtime"/>
+ <element ref="default-parameter-value"/>
</choice>
<attribute name="name" type="string" use="required">
<annotation>
@@ -183,7 +185,7 @@
</complexType>
</element>
- <element name="empty-project">
+ <element name="runtime-template">
<annotation>
<documentation>
This element describes contents that will be added to all projects for given runtime.
@@ -191,8 +193,9 @@
</annotation>
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
- <element ref="template"/>
+ <element ref="archive"/>
<element ref="installer"/>
+ <element ref="default-parameter-value"/>
</choice>
<attribute name="runtime-id" type="string" use="required">
<annotation>
@@ -214,6 +217,28 @@
</complexType>
</element>
+ <element name="default-parameter-value">
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="value" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<annotation>
<appinfo>
<meta.section type="since"/>
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateImpl.java Fri Aug 13 16:28:00 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateImpl.java Fri Aug 13 17:26:00 2010 -0700
@@ -18,6 +18,9 @@
*/
package org.symbian.tools.tmw.internal.ui.project;
+import java.util.Map;
+import java.util.TreeMap;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -42,6 +45,7 @@
private IMobileWebRuntime[] runtimes;
private IProjectFacetVersion[] facetVersions;
private ITemplateInstaller installer;
+ private Map<String, String> parameters;
public ProjectTemplateImpl(IConfigurationElement element) {
this.element = element;
@@ -142,4 +146,16 @@
monitor.done();
}
+ public Map<String, String> getDefaultParameterValues() {
+ if (parameters == null) {
+ parameters = new TreeMap<String, String>();
+ for (IConfigurationElement el : element.getChildren()) {
+ if ("default-parameter-value".equals(el.getName())) {
+ parameters.put(el.getAttribute("name"), el.getAttribute("value"));
+ }
+ }
+ }
+ return parameters;
+ }
+
}
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateManagerImpl.java Fri Aug 13 16:28:00 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateManagerImpl.java Fri Aug 13 17:26:00 2010 -0700
@@ -19,9 +19,11 @@
package org.symbian.tools.tmw.internal.ui.project;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.TreeMap;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
@@ -34,6 +36,7 @@
public class ProjectTemplateManagerImpl implements IProjectTemplateManager {
private Map<IMobileWebRuntime, ITemplateInstaller> emptyProjects;
+ private Map<IMobileWebRuntime, Map<String, String>> runtimeTemplateParameters;
private Map<IMobileWebRuntime, IProjectTemplate[]> templates;
public IProjectTemplate getDefaultTemplate(IMobileWebRuntime runtime) {
@@ -60,6 +63,7 @@
}
private Map<IMobileWebRuntime, IProjectTemplate[]> readExtensions() {
+ runtimeTemplateParameters = new HashMap<IMobileWebRuntime, Map<String, String>>();
emptyProjects = new HashMap<IMobileWebRuntime, ITemplateInstaller>();
final Map<IMobileWebRuntime, Collection<IProjectTemplate>> map = new HashMap<IMobileWebRuntime, Collection<IProjectTemplate>>();
final IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
@@ -76,12 +80,23 @@
}
tmplts.add(template);
}
- } else if ("empty-project".equals(element.getName())) {
+ } else if ("runtime-template".equals(element.getName())) {
final String runtimeId = element.getAttribute("runtime-id");
final String runtimeVersion = element.getAttribute("version");
final IMobileWebRuntime runtime = TMWCore.getRuntimesManager().getRuntime(runtimeId, runtimeVersion);
if (runtime != null) {
- emptyProjects.put(runtime, CompoundInstaller.combine(emptyProjects.get(runtime), elements));
+ emptyProjects.put(runtime,
+ CompoundInstaller.combine(emptyProjects.get(runtime), element.getChildren()));
+ Map<String, String> params = runtimeTemplateParameters.get(runtime);
+ if (params == null) {
+ params = new TreeMap<String, String>();
+ runtimeTemplateParameters.put(runtime, params);
+ }
+ for (IConfigurationElement el : element.getChildren()) {
+ if ("default-parameter-value".equals(el.getName())) {
+ params.put(el.getAttribute("name"), el.getAttribute("value"));
+ }
+ }
}
}
}
@@ -93,4 +108,15 @@
}
return res;
}
+
+ public Map<String, String> getDefaultTemplateParameterValues(IMobileWebRuntime runtime) {
+ if (runtimeTemplateParameters == null) {
+ readExtensions();
+ }
+ Map<String, String> params = runtimeTemplateParameters.get(runtime);
+ if (params == null) {
+ return Collections.emptyMap();
+ }
+ return params;
+ }
}
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java Fri Aug 13 16:28:00 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java Fri Aug 13 17:26:00 2010 -0700
@@ -243,6 +243,14 @@
private Map<String, String> getTemplateVars() {
Map<String, String> vars = new TreeMap<String, String>();
+ if (runtime != null) {
+ vars.putAll(TMWCoreUI.getProjectTemplateManager().getDefaultTemplateParameterValues(runtime));
+ }
+ final IProjectTemplate t = getTemplate();
+ if (t != null) {
+ vars.putAll(t.getDefaultParameterValues());
+ }
+
vars.put("widgetName", getWidgetName());
vars.put("widgetId", getWidgetId());
// vars.put("mainHtml", getHtmlFileName());
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/ui/project/IProjectTemplate.java Fri Aug 13 16:28:00 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/ui/project/IProjectTemplate.java Fri Aug 13 17:26:00 2010 -0700
@@ -18,6 +18,8 @@
*/
package org.symbian.tools.tmw.ui.project;
+import java.util.Map;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.graphics.Image;
@@ -82,4 +84,9 @@
* Initializes project with template contents
*/
void init(IProject project, IProjectTemplateContext context, IProgressMonitor monitor);
+
+ /**
+ * Returns default template parameter values
+ */
+ Map<String, String> getDefaultParameterValues();
}
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/ui/project/IProjectTemplateManager.java Fri Aug 13 16:28:00 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/ui/project/IProjectTemplateManager.java Fri Aug 13 17:26:00 2010 -0700
@@ -18,10 +18,17 @@
*/
package org.symbian.tools.tmw.ui.project;
+import java.util.Map;
+
import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime;
public interface IProjectTemplateManager {
IProjectTemplate[] getProjectTemplates(IMobileWebRuntime runtime);
IProjectTemplate getDefaultTemplate(IMobileWebRuntime runtime);
ITemplateInstaller getEmptyProjectTemplate(IMobileWebRuntime runtime);
+
+ /**
+ * Runtimes can provide default values for template parameters
+ */
+ Map<String, String> getDefaultTemplateParameterValues(IMobileWebRuntime runtime);
}
--- a/org.symbian.tools.wrttools/plugin.xml Fri Aug 13 16:28:00 2010 -0700
+++ b/org.symbian.tools.wrttools/plugin.xml Fri Aug 13 17:26:00 2010 -0700
@@ -851,7 +851,42 @@
<archive
file="projecttemplates/flickr.zip">
</archive>
+ <default-parameter-value
+ name="mainCss"
+ value="style">
+ </default-parameter-value>
+ <default-parameter-value
+ name="mainJs"
+ value="flickr">
+ </default-parameter-value>
+ <default-parameter-value
+ name="mainHtml"
+ value="flickr">
+ </default-parameter-value>
</template>
+ <runtime-template
+ runtime-id="org.symbian.tools.wrttools.wrt"
+ version="1.1">
+ <archive
+ file="projecttemplates/basic.zip">
+ </archive>
+ <default-parameter-value
+ name="homeScreen"
+ value="false">
+ </default-parameter-value>
+ <default-parameter-value
+ name="mainHtml"
+ value="index">
+ </default-parameter-value>
+ <default-parameter-value
+ name="mainCss"
+ value="basic">
+ </default-parameter-value>
+ <default-parameter-value
+ name="mainJs"
+ value="basic">
+ </default-parameter-value>
+ </runtime-template>
</extension>
</plugin>
Binary file org.symbian.tools.wrttools/projecttemplates/basic.zip has changed
Binary file org.symbian.tools.wrttools/projecttemplates/flickr.zip has changed