# HG changeset patch # User Eugene Ostroukhov # Date 1282695676 25200 # Node ID 6c07c755d0c719e74fe9dd61641c61d2845b75ff # Parent b616697678bf4db8321c3eade3a5090bf713a76a PhoneGap template will use proper screen size diff -r b616697678bf -r 6c07c755d0c7 plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/projects/ITMWProject.java --- 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 true 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(); } diff -r b616697678bf -r 6c07c755d0c7 plugins/org.symbian.tools.tmw.previewer/META-INF/MANIFEST.MF --- 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, diff -r b616697678bf -r 6c07c755d0c7 plugins/org.symbian.tools.tmw.previewer/src/org/symbian/tools/tmw/previewer/http/handlers/PreferencesResourceProvider.java --- 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 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 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) { diff -r b616697678bf -r 6c07c755d0c7 plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateManagerImpl.java --- 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 { + 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 emptyProjects; private Map> runtimeTemplateParameters; private Map templates; @@ -75,7 +92,7 @@ for (IMobileWebRuntime runtime : supportedRuntimes) { Collection tmplts = map.get(runtime); if (tmplts == null) { - tmplts = new HashSet(); + tmplts = new TreeSet(new TemplateComparator()); map.put(runtime, tmplts); } tmplts.add(template); diff -r b616697678bf -r 6c07c755d0c7 plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/WizardContext.java --- 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 jsIncludes = new TreeSet(); diff -r b616697678bf -r 6c07c755d0c7 plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/ProjectMemo.java --- 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; + } + } diff -r b616697678bf -r 6c07c755d0c7 plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/project/IProjectTemplateManager.java --- 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); diff -r b616697678bf -r 6c07c755d0c7 plugins/org.symbian.tools.wrttools/plugin.xml --- 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"> + +