Bug 3251 - phonegap project - Vibrate text overflows button size
authorEugene Ostroukhov <eugeneo@symbian.org>
Wed, 14 Jul 2010 16:18:46 -0700
changeset 448 4bb763ad2b12
parent 447 a66f421f3a32
child 449 fb993a790bc4
Bug 3251 - phonegap project - Vibrate text overflows button size
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreferencesResourceProvider.java
org.symbian.tools.wrttools/plugin.xml
org.symbian.tools.wrttools/projecttemplates/phonegap.zip
org.symbian.tools.wrttools/schema/projectTemplates.exsd
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/WRTProject.java
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/ProjectTemplate.java
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreferencesResourceProvider.java	Wed Jul 14 15:18:37 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreferencesResourceProvider.java	Wed Jul 14 16:18:46 2010 -0700
@@ -29,6 +29,7 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.json.simple.JSONObject;
+import org.symbian.tools.wrttools.WRTProject;
 import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
 import org.symbian.tools.wrttools.previewer.preview.ProjectPreferencesManager;
 
@@ -41,6 +42,12 @@
             String sessionId)
             throws IOException, CoreException {
         Properties projectPreferences = ProjectPreferencesManager.getProjectProperties(project);
+        if (!projectPreferences.containsKey("__SYM_NOKIA_EMULATOR_DEVICE")) {
+            String resolution = new WRTProject(project).getPreferredScreenSize();
+            if (resolution != null) {
+                projectPreferences.put("__SYM_NOKIA_EMULATOR_DEVICE", resolution);
+            }
+        }
         String js = getJS(projectPreferences);
         try {
             return new ByteArrayInputStream(js.getBytes("UTF-8"));
--- a/org.symbian.tools.wrttools/plugin.xml	Wed Jul 14 15:18:37 2010 -0700
+++ b/org.symbian.tools.wrttools/plugin.xml	Wed Jul 14 16:18:46 2010 -0700
@@ -154,7 +154,8 @@
             default-js-name="main"
             icon="icons/phonegap.png"
             name="PhoneGap Application"
-            order="2">
+            order="2"
+            screen-size="360x640">
          <description>
             This wizard generates a project based on the PhoneGap library that showcases PhoneGap API usage. PhoneGap applications require WRT 1.1 or newer.
          </description>
@@ -196,8 +197,9 @@
             default-html-name="index"
             default-js-name="basic"
             icon="icons/main16.gif"
+            name="Various UI Templates"
             order="5"
-            name="Various UI Templates">
+            screen-size="360x640">
          <description>
             Includes templates for high-end devices from Forum.Nokia.
          </description>
Binary file org.symbian.tools.wrttools/projecttemplates/phonegap.zip has changed
--- a/org.symbian.tools.wrttools/schema/projectTemplates.exsd	Wed Jul 14 15:18:37 2010 -0700
+++ b/org.symbian.tools.wrttools/schema/projectTemplates.exsd	Wed Jul 14 16:18:46 2010 -0700
@@ -1,177 +1,184 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.symbian.tools.wrttools.editing.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
-      <appinfo>
-         <meta.schema plugin="org.symbian.tools.wrttools.editing.core" id="projectTemplates" name="WRT application project templates"/>
-      </appinfo>
-      <documentation>
-         [Enter description of this extension point.]
-      </documentation>
-   </annotation>
-
-   <element name="extension">
-      <annotation>
-         <appinfo>
-            <meta.element />
-         </appinfo>
-      </annotation>
-      <complexType>
-         <sequence minOccurs="0" maxOccurs="unbounded">
-            <element ref="projectTemplate"/>
-         </sequence>
-         <attribute name="point" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="id" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="name" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-               <appinfo>
-                  <meta.attribute translatable="true"/>
-               </appinfo>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
-   <element name="projectTemplate">
-      <complexType>
-         <sequence minOccurs="1" maxOccurs="unbounded">
-            <choice>
-               <element ref="description"/>
-               <element ref="requires-library" minOccurs="0" maxOccurs="unbounded"/>
-            </choice>
-         </sequence>
-         <attribute name="name" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-               <appinfo>
-                  <meta.attribute translatable="true"/>
-               </appinfo>
-            </annotation>
-         </attribute>
-         <attribute name="icon" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-               <appinfo>
-                  <meta.attribute kind="resource"/>
-               </appinfo>
-            </annotation>
-         </attribute>
-         <attribute name="archive" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-               <appinfo>
-                  <meta.attribute kind="resource"/>
-               </appinfo>
-            </annotation>
-         </attribute>
-         <attribute name="default-html-name" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="default-css-name" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="default-js-name" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="wizard-page-factory" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-               <appinfo>
-                  <meta.attribute kind="java" basedOn=":org.symbian.tools.wrttools.editing.core.wizard.IWizardPageFactory"/>
-               </appinfo>
-            </annotation>
-         </attribute>
-         <attribute name="order" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
-   <element name="description" type="string">
-      <annotation>
-         <appinfo>
-            <meta.element translatable="true"/>
-         </appinfo>
-      </annotation>
-   </element>
-
-   <element name="requires-library" type="string">
-   </element>
-
-   <annotation>
-      <appinfo>
-         <meta.section type="since"/>
-      </appinfo>
-      <documentation>
-         [Enter the first release in which this extension point appears.]
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appinfo>
-         <meta.section type="examples"/>
-      </appinfo>
-      <documentation>
-         [Enter extension point usage example here.]
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appinfo>
-         <meta.section type="apiinfo"/>
-      </appinfo>
-      <documentation>
-         [Enter API information here.]
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appinfo>
-         <meta.section type="implementation"/>
-      </appinfo>
-      <documentation>
-         [Enter information about supplied implementation of this extension point.]
-      </documentation>
-   </annotation>
-
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.symbian.tools.wrttools.editing.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.symbian.tools.wrttools.editing.core" id="projectTemplates" name="WRT application project templates"/>
+      </appinfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="0" maxOccurs="unbounded">
+            <element ref="projectTemplate"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="projectTemplate">
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <choice>
+               <element ref="description"/>
+               <element ref="requires-library" minOccurs="0" maxOccurs="unbounded"/>
+            </choice>
+         </sequence>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="icon" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="resource"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="archive" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="resource"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="default-html-name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="default-css-name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="default-js-name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="wizard-page-factory" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":org.symbian.tools.wrttools.editing.core.wizard.IWizardPageFactory"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="screen-size" type="string">
+            <annotation>
+               <documentation>
+                  This template is for touch devices
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="order" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="description" type="string">
+      <annotation>
+         <appinfo>
+            <meta.element translatable="true"/>
+         </appinfo>
+      </annotation>
+   </element>
+
+   <element name="requires-library" type="string">
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/WRTProject.java	Wed Jul 14 15:18:37 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/WRTProject.java	Wed Jul 14 16:18:46 2010 -0700
@@ -39,6 +39,7 @@
     private static final IPath PROPERTIES_FILE = new Path(".settings").append(Activator.PLUGIN_ID + ".properties");
     private static final String PROP_DEPLOYMENT_TARGET_NAME = "deployment.target.name";
     private static final String PROP_DEPLOYMENT_TARGET_TYPE = "deployment.target.type";
+    private static final String PROP_PREFERED_SCREEN = "preferred.screen.size";
     private final IProject project;
 
     public WRTProject(IProject project) {
@@ -103,9 +104,7 @@
             if (!file.exists()) {
                 file.create(new ByteArrayInputStream(stream.toByteArray()), false, new NullProgressMonitor());
             } else {
-                file
-                        .setContents(new ByteArrayInputStream(stream.toByteArray()), false, true,
-                                new NullProgressMonitor());
+                file.setContents(new ByteArrayInputStream(stream.toByteArray()), false, true, new NullProgressMonitor());
             }
         } catch (IOException e) {
             Activator.log(e);
@@ -117,4 +116,18 @@
     public IProject getProject() {
         return project;
     }
+
+    public void setPreferredScreenSize(String screenSize) {
+        Properties props = getProps();
+        if (screenSize != null) {
+            props.put(PROP_PREFERED_SCREEN, screenSize);
+        } else {
+            props.remove(PROP_PREFERED_SCREEN);
+        }
+        saveProperties(props);
+    }
+
+    public String getPreferredScreenSize() {
+        return getProps().getProperty(PROP_PREFERED_SCREEN);
+    }
 }
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/ProjectTemplate.java	Wed Jul 14 15:18:37 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/ProjectTemplate.java	Wed Jul 14 16:18:46 2010 -0700
@@ -40,9 +40,7 @@
 
 public class ProjectTemplate {
     private static ProjectTemplate[] templates;
-
     private final IConfigurationElement element;
-
     private Image icon;
 
     public ProjectTemplate(IConfigurationElement element) {
@@ -54,8 +52,7 @@
             String path = element.getAttribute("icon");
             final ImageDescriptor imageDescriptor;
             if (path != null) {
-                imageDescriptor = Activator.imageDescriptorFromPlugin(
-                        element.getNamespaceIdentifier(), path);
+                imageDescriptor = Activator.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), path);
             } else {
                 imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
             }
@@ -78,8 +75,7 @@
     }
 
     private String[] getLibraryIds() {
-        IConfigurationElement[] elements = element
-                .getChildren("requires-library");
+        IConfigurationElement[] elements = element.getChildren("requires-library");
         String[] ids = new String[elements.length];
         for (int i = 0; i < elements.length; i++) {
             IConfigurationElement element = elements[i];
@@ -90,8 +86,8 @@
 
     public static ProjectTemplate[] getAllTemplates() {
         if (templates == null) {
-            IExtensionPoint point = Platform.getExtensionRegistry()
-                    .getExtensionPoint(Activator.PLUGIN_ID, "projectTemplates");
+            IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID,
+                    "projectTemplates");
             IConfigurationElement[] elements = point.getConfigurationElements();
             templates = new ProjectTemplate[elements.length];
             for (int i = 0; i < elements.length; i++) {
@@ -117,8 +113,7 @@
         return file != null ? file : "index";
     }
 
-    public WRTProjectFilesWizardPage createWizardPage(WizardContext context,
-            DataBindingContext bindingContext) {
+    public WRTProjectFilesWizardPage createWizardPage(WizardContext context, DataBindingContext bindingContext) {
         try {
             if (element.getAttribute("wizard-page-factory") != null) {
                 IWizardPageFactory factory = (IWizardPageFactory) element
@@ -139,8 +134,7 @@
     public URL getProjectContents() {
         String uri = element.getAttribute("archive");
         if (uri != null) {
-            Bundle bundle = Platform.getBundle(element.getContributor()
-                    .getName());
+            Bundle bundle = Platform.getBundle(element.getContributor().getName());
             URL resource = bundle.getResource(uri);
             return resource;
         }
@@ -175,4 +169,8 @@
         }
         return Integer.MAX_VALUE;
     }
+
+    public String getScreenSize() {
+        return element.getAttribute("screen-size");
+    }
 }
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java	Wed Jul 14 15:18:37 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java	Wed Jul 14 16:18:46 2010 -0700
@@ -57,6 +57,7 @@
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
 import org.symbian.tools.wrttools.Activator;
+import org.symbian.tools.wrttools.WRTProject;
 import org.symbian.tools.wrttools.core.ProjectTemplate;
 import org.symbian.tools.wrttools.core.WRTImages;
 import org.symbian.tools.wrttools.core.libraries.JSLibrary;
@@ -151,7 +152,9 @@
 
     private void populateProject(IProject project, IProgressMonitor monitor)
             throws CoreException {
-        URL projectContents = context.getTemplate().getProjectContents();
+        ProjectTemplate t = context.getTemplate();
+        new WRTProject(project).setPreferredScreenSize(t.getScreenSize());
+        URL projectContents = t.getProjectContents();
         Map<String, String> vars = context.getTemplateVars();
 
         ZipInputStream stream = null;