This tutorial will guide you through installing and using RhoStudio in the Eclipse IDE.
This tutorial assumes that you have installed Eclipse version 3.6.2 (Helios) or later: a version with a Java runtime environment, such as Eclipse IDE for Java Developers. If you do not know how to do this, see Pre-requisite Reading. It also assumes you have Rhodes 2.4 or higher installed.
This tutorial also assumes that you have installed the SDK for your platform. Xcode (iPhone, iPad) requires a Macintosh; Windows Mobile and Blackberry require Windows.
Install the Dynamic Languages Toolkit for Ruby if you have not already done so. This allows you to have well-formatted Ruby syntax in Eclipse.
In Eclipse, select Help –> Install New Software. Enter the website http://download.eclipse.org/releases/helios. From Programming Languages, select Dynamic Languages Toolkit – Ruby, and install it.
To install RhoStudio into your Eclipse, select Help –> Install New Software. In the Install window, click the Add button. In the Add Repository window, enter RhoStudio for Name, and http://rhostudio.rhomobile.com for Location.
Check RhoStudio, click Next, and follow the instructions.
You may need to set paths for RhoStudio to work properly. For example, default paths that work on a Windows computer will not work on a Macintosh. You can edit the paths in Eclipse Preferences.
In the webinar video, this is discussed at 13:20, near the end.
If you are on a Macintosh, you will likely need to set your path to your Java JDK, which are likely set to a default Windows path.
Select Eclipse –> Preferences. Select Rhomobile. Click the Browse buttons and set your path to your Java JDK, which is likely similar to /Library/Java/Home/bin. Click Apply, then OK.
When you want to run a project for Android, Windows Mobile, or Blackberry, you should check your paths to their development environments.
Select Eclipse –> Preferences. Under Rhomobile, select the platform. For Android, click the Browse buttons and set your paths to your Android SDK and NDK. Click Apply, then OK.
For Blackberry, you can set to a Blackberry version, the Blackberry JDE path, the Blackberry MDS path, and the Simulator device. For Windows Mobile, you can set your path to your Windows Mobile SDK.
Development for Windows Mobile and Blackberry requires a Windows computer. Development for iPhone or iPad requires a Macintosh.
This tutorial uses a store project as its example.
Select File –> New –> Project. In the New Project window, select Rhodes application from the Rhomobile folder. Click Next.
In the Rhodes application generator wizard window, enter store for the project name. Click Finish.
In the Eclipse Package Explorer, you see that you now have a complete Rhodes project. If you open one of its Ruby files, such as app/Product/product_controller.rb, you can see that the Dynamic Language Toolkit gives you nice Ruby syntax highlighting.
In the Package Explorer for the Store project, click on build.yml. The build.yml file opens in a yml editor. You can edit the Application name, and you can enter a name for an Application log file. In the Rhodes folder path, you can edit which Rhodes SDK you use for your project; the example here shows Rhodes 3.0, which happens to be the default for this example. Note that you need Rhodes 2.4 or higher to use RhoStudio.
Now you can run your Rhodes project. Select your Rhodes project in the Package Explorer. Select Run –> Run Configurations. From the Run Configurations window, enter the name you want for the configuration (iPhone simulate in this example), and from the Platform drop-down menu, select the platform you want to run (iPhone simulator in the example).
You can check “Clean before build” if you wish, but this will make your build take a little longer.
Click Apply to save your changes. Then click Run.
You will see your project building in the Rhodes build console, with the usual messages that you would see if you had instead built your project from the command line. When your Rhodes project has built, and then runs (in this example, when the iPhone simulator appears), the build console switches to the Rhodes application console.
Now you can add a model to your project. Control-click on your Rhodes project in the Package Explorer. Note that since this example uses the iPhone simulator, and therefore it is being run on a Macintosh, you use Control-click, whereas on WIndows, you would right-click.
You will see a new option called Rhomobile. Select Rhomobile –> Rhodes model.
In the Model Information window, you create a model in your Rhodes project. For the Store example, create a model called product, with attributes of name,price,quantity,sku,brand. Note that you do not put spaces between the attributes.
You will see the product model created in your Rhodes project, with the folder for your model and all the generated files, such as app/Product/product_controller.rb.
You need to add a link to this model in your top-level page. In app/index.erb, edit the list to add a link to the product model.
<div class="content"> <ul> <li> <!-- Edited to link with Product --> <a href="Product"><span class="title">Products</span><span class="disclosure_indicator"/></a> </li> </ul> </div>
Now run your configuration again. You will see the Product link.
In the iPhone simulator, click the Products link, then click New. Enter the data for a new Product, such as iPhone, $199.99, 5, 12345, and Apple for name, price, quantity, sku, and brand. Then click Create. You will see your model, which is stored in the local database for Rhodes.
Note that this model generator works similar to the command line. It uses the command line tool to generate the models, and you can even run it from the command line, switching back and forth from Eclipse if you desire.
Quit the iPhone simulator. Time to run your project in Android.
Select your Rhodes project in the Package Explorer. Select Run –> Run Configurations. From the Run Configurations window, enter the name you want for the configuration (rhoAndroid233 in the example), and from the Platform drop-down menu, select Android emulator. This example selects 2.3.3 as the version; for now, you have to have the Android simulator version already created to select it. For your Store project, enter a name, such as Android simulate, and an AVD (Android Virtual Device) name, such as rhoAndroid233. Click Run.
You will see your Rhodes project running on an Android virtual device, and it has the Product model and link that you already put into your Store project.
In the Android emulator, click the Products link, then click New. Enter the data for a new Product, such as iPhone, $199.99, 3, 12345, and Apple for name, price, quantity, sku, and brand. Then click Create. You will see your model, which is stored in the local database for Rhodes.