--- a/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/projects/ITMWProject.java Tue Aug 24 15:17:50 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/projects/ITMWProject.java Tue Aug 24 17:21:16 2010 -0700
@@ -44,11 +44,4 @@
* @return <code>true</code> if the project has no errors. Warnings do not count.
*/
boolean validate(IProgressMonitor monitor);
-
- /**
- * Return preferred screen size for the project.
- *
- * @return string like "240x320"
- */
- String getPreferredScreenSize();
}
--- a/plugins/org.symbian.tools.tmw.previewer/META-INF/MANIFEST.MF Tue Aug 24 15:17:50 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.previewer/META-INF/MANIFEST.MF Tue Aug 24 17:21:16 2010 -0700
@@ -14,7 +14,8 @@
org.eclipse.wst.jsdt.ui;bundle-version="1.0.200",
org.mozilla.xulrunner;bundle-version="1.9.1";resolution:=optional,
org.eclipse.ui.console;bundle-version="3.5.0",
- org.symbian.tools.tmw.core;bundle-version="1.0.0"
+ org.symbian.tools.tmw.core;bundle-version="1.0.0",
+ org.symbian.tools.tmw.ui;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.symbian.tools.tmw.previewer.core,
--- a/plugins/org.symbian.tools.tmw.previewer/src/org/symbian/tools/tmw/previewer/http/handlers/PreferencesResourceProvider.java Tue Aug 24 15:17:50 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.previewer/src/org/symbian/tools/tmw/previewer/http/handlers/PreferencesResourceProvider.java Tue Aug 24 17:21:16 2010 -0700
@@ -33,6 +33,7 @@
import org.symbian.tools.tmw.core.projects.ITMWProject;
import org.symbian.tools.tmw.previewer.PreviewerPlugin;
import org.symbian.tools.tmw.previewer.preview.ProjectPreferencesManager;
+import org.symbian.tools.tmw.ui.ProjectMemo;
public class PreferencesResourceProvider implements IResourceProvider {
public String[] getPaths() {
@@ -40,16 +41,16 @@
}
public InputStream getResourceStream(IProject project, IPath resource, Map<String, String[]> parameters,
- String sessionId)
- throws IOException, CoreException {
+ String sessionId) throws IOException, CoreException {
Properties projectPreferences = ProjectPreferencesManager.getProjectProperties(project);
if (!projectPreferences.containsKey("__SYM_NOKIA_EMULATOR_DEVICE")) {
final ITMWProject p = TMWCore.create(project);
if (p != null) {
- String resolution = p.getPreferredScreenSize();
- if (resolution != null) {
- projectPreferences.put("__SYM_NOKIA_EMULATOR_DEVICE", resolution);
- }
+ ProjectMemo memo = new ProjectMemo(p);
+ String resolution = memo.getAttribute("resolution");
+ if (resolution != null) {
+ projectPreferences.put("__SYM_NOKIA_EMULATOR_DEVICE", resolution);
+ }
}
}
String js = getJS(projectPreferences);
@@ -71,8 +72,7 @@
}
public void post(IProject project, IPath resource, Map<String, String[]> parameterMap, JSONObject object,
- String sessionId)
- throws IOException, CoreException {
+ String sessionId) throws IOException, CoreException {
String key = (String) object.get("key");
Object value = object.get("value");
if (value != null) {
--- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateManagerImpl.java Tue Aug 24 15:17:50 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateManagerImpl.java Tue Aug 24 17:21:16 2010 -0700
@@ -20,10 +20,11 @@
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.TreeMap;
+import java.util.TreeSet;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
@@ -35,6 +36,22 @@
import org.symbian.tools.tmw.ui.project.ITemplateInstaller;
public class ProjectTemplateManagerImpl implements IProjectTemplateManager {
+ public class TemplateComparator implements Comparator<IProjectTemplate> {
+ public int compare(IProjectTemplate o1, IProjectTemplate o2) {
+ if (o1 == o2) {
+ return 0;
+ } else if (o1 == null) {
+ return -1;
+ } else if (o2 == null) {
+ return 1;
+ }
+ if (o1.getWeight() == o2.getWeight()) {
+ return o1.getName().compareTo(o2.getName());
+ } else {
+ return o1.getWeight() > o2.getWeight() ? 1 : -1;
+ }
+ }
+ }
private Map<IMobileWebRuntime, ITemplateInstaller> emptyProjects;
private Map<IMobileWebRuntime, Map<String, String>> runtimeTemplateParameters;
private Map<IMobileWebRuntime, IProjectTemplate[]> templates;
@@ -75,7 +92,7 @@
for (IMobileWebRuntime runtime : supportedRuntimes) {
Collection<IProjectTemplate> tmplts = map.get(runtime);
if (tmplts == null) {
- tmplts = new HashSet<IProjectTemplate>();
+ tmplts = new TreeSet<IProjectTemplate>(new TemplateComparator());
map.put(runtime, tmplts);
}
tmplts.add(template);
--- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java Tue Aug 24 15:17:50 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java Tue Aug 24 17:21:16 2010 -0700
@@ -55,9 +55,7 @@
private final PropertyChangeSupport propertySupport = new PropertyChangeSupport(this);
private IMobileWebRuntime runtime;
private IProjectTemplate template = null;
-
private String widgetId;
-
private String widgetName;
private final Collection<String> jsIncludes = new TreeSet<String>();
--- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/ProjectMemo.java Tue Aug 24 15:17:50 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/ProjectMemo.java Tue Aug 24 17:21:16 2010 -0700
@@ -31,6 +31,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.XMLMemento;
+import org.symbian.tools.tmw.core.TMWCore;
import org.symbian.tools.tmw.core.projects.ITMWProject;
import org.symbian.tools.tmw.ui.deployment.IDeploymentTarget;
import org.symbian.tools.tmw.ui.deployment.IDeploymentTargetType;
@@ -137,4 +138,30 @@
return null;
}
+ public void setAttribute(String name, String value) {
+ try {
+ checkMemento();
+ memento.putString(name, value);
+ saveMemento();
+ } catch (CoreException e) {
+ TMWCoreUI.log(e);
+ } catch (IOException e) {
+ TMWCoreUI.log(e);
+ }
+ }
+
+ public String getAttribute(String name) {
+ try {
+ checkMemento();
+ } catch (CoreException e) {
+ TMWCore.log(null, e);
+ } catch (IOException e) {
+ TMWCore.log(null, e);
+ }
+ if (memento != null) {
+ return memento.getString(name);
+ }
+ return null;
+ }
+
}
--- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/project/IProjectTemplateManager.java Tue Aug 24 15:17:50 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/project/IProjectTemplateManager.java Tue Aug 24 17:21:16 2010 -0700
@@ -23,6 +23,11 @@
import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime;
public interface IProjectTemplateManager {
+ /**
+ * Returns project templates that support mobile web runtime.
+ *
+ * @return sorted array of the templates. Templates are sorted based on weight and name.
+ */
IProjectTemplate[] getProjectTemplates(IMobileWebRuntime runtime);
IProjectTemplate getDefaultTemplate(IMobileWebRuntime runtime);
--- a/plugins/org.symbian.tools.wrttools/plugin.xml Tue Aug 24 15:17:50 2010 -0700
+++ b/plugins/org.symbian.tools.wrttools/plugin.xml Tue Aug 24 17:21:16 2010 -0700
@@ -892,6 +892,9 @@
name="mainHtml"
value="index">
</default-parameter-value>
+ <installer
+ class="org.symbian.tools.wrttools.core.project.SetResolution">
+ </installer>
</template>
<template
icon="icons/main16.gif"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/project/SetResolution.java Tue Aug 24 17:21:16 2010 -0700
@@ -0,0 +1,63 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.core.project;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.symbian.tools.tmw.core.TMWCore;
+import org.symbian.tools.tmw.core.projects.ITMWProject;
+import org.symbian.tools.tmw.ui.ProjectMemo;
+import org.symbian.tools.tmw.ui.project.IProjectTemplateContext;
+import org.symbian.tools.tmw.ui.project.ITemplateInstaller;
+
+public class SetResolution implements ITemplateInstaller {
+ private IProject project;
+
+ public void prepare(IProject project, IProjectTemplateContext context) {
+ this.project = project;
+ }
+
+ public void cleanup() {
+ project = null;
+ }
+
+ public IPath[] getFiles() throws CoreException {
+ return new IPath[0];
+ }
+
+ public void copyFiles(IPath[] files, IProgressMonitor monitor) throws CoreException {
+ // Do nothing
+ }
+
+ public IRunnableWithProgress getPostCreateAction() {
+ final IProject p = project;
+ return new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ ITMWProject tmw = TMWCore.create(p);
+ new ProjectMemo(tmw).setAttribute("resolution", "360x640");
+ }
+ };
+ }
+
+}