Sunday, May 5, 2013

How to use Sencha Touch 2 in Eclipse with Auto Complete feature.

We know Sencha Touch 2 is going to be a promising frame work for cross platform mobile app development. Inspite of the greate Sencha SDK provided, it's a pity that they do not provide Sencha Architect (the ultimate Sencha Touch IDE) for free ! Here I discuss how we can use Sencha in our old friend Eclipse. One thing I wanted for a while was to have the auto complete feature for Sencha API in Eclipse. Even though Googled, resources and the instructions provided  in other articles are obsolete by the time I write this. After few days I realized a way that I can enable the auto complete feature in Eclipse for Sencha Touch 2 and thought to share my experience with you, who might be desperate as I was.

Prerequisites :

Sencha SDK (used here : sencha-touch-2.1.1)
Sencha Cmd (used here : Sencha Cmd 3.1.1)
An Eclipse IDE (used here : Kepler: Eclipse Java EE IDE for Web Developers)

How to Open & Run a Sencha Touch app inside Eclipse

  • Create a Sencha app skelton using sencha cmd (I have discussed this in my previous post).
  • Then open Eclipse IDE and go to File menu -> other -> general -> Project
  • Give a Name to the project and dis-select the 'use default location' option and browse and provide the Sencha app skelton folder we created previously.


  • Configure the Tom Cat server in Eclipse.
  • Run the app in the server mode.   
  • If everything works fine you'll be able to view your running app at 'http://localhost:8080/<your sencha app name>/' (port number might defer according to the server configurations if its not the default) in the chrome browser. (since Sencha Touch is a JavaScript application framework developed for mobile web applications development, it supports only web browsers built on Web Kit. So you must use Chrome or Safari for testing on desktop PCs)

Enabling the Auto Complete feature for Sencha Touch 2

  • In the Eclipse IDE go to Help -> Install New Software and click Add button.
  • On the Name field type 'Spket' and for the location type 'http://www.agpad.com/update/' and click Ok button. Spket is a free toolkit for Java Script and it provides a plugin for Eclipse. (http://www.spket.com/)






  • Select all the components and click 'Next'.

  • Click Next again.

  • Select 'I accept the terms ... ' and click 'Finish'.

  • Wait a while till Spket gets installed and at the middle it may give a security warning, then press "OK". At the end it will prompt you to restart Eclipse, and please do.



Setting up Sencha Touch2 for auto completion

  • Now go to Ecplise IDE and go to 'Window' -> Prefernces -> Spket -> Editors -> Java Script Profiles, and click New.
  • Type 'Sencha Touch' and click 'Ok'.
  • Select 'Sencha Touch' from the library and click on 'Add Library'.
  • Select EXT JS.
  • Select the second 'ExtJS' option and click 'Add File'
  • Select touch.jsb3 file saved in Sencha SDK and click 'Open'.
  • select all components and select the first 'Sencha Touch' node and click 'Default' and press 'OK'.
  • Now within the 'preferences' window select General -> Editors -> File Associations and select '*.js' fro the list. Under the Associated Editors list select 'Spket Java Script Editor' and click 'Default' button and click 'Ok'.
  • If everything happened smooth you should now be able to try out auto completion feature for Sencha Touch 2 in eclipse. Type Ext. and press (ctrl + space) voila!    
Note: for Mac users this post might be helpful despite of touch.jsb3 file.
If you are interested you can even have this capability in Aptana or Titanium : refer this