Installing Cairngorm Plug-in in Flex Builder 3
Lately I started working on a project that uses Cairngorm as an MVC framework for flex application. As in many MVC frameworks you quickly found yourself coding the same skeleton of code over and over again. Then I run into the Cairngorm plug-in.
As specified in the plug-in web page: The Cairngorm Plug-in is an Eclipse plug-in that augments Flex Builder to provide tooling that improves productivity when developing Cairngorm. It aims to improve productivity by removing the repetitive action of creating a new Command and associated Event and adding them to the Controller.
It provides a new class wizard for the following Cairngorm artifacts:
· Controller - creates a new Controller
· Command - creates a new Event and a new Command and adds them to the Controller.
The class templates used for the codegen are externalized and distributed with Cairngorm. This allows you to modify the templates to support your own code style.
I personally found the installation and usage rather tricky so I decided to collect some pitfalls I run into.
For detailed information repair to the Cairngorm plug-in web site http://opensource.adobe.com/wiki/display/cairngorm/Plugin
Pitfall 1: Flex builder fails to resolve dependencies for the Cairngorm plug-in
When you install the plug-in the following error is displayed in the Flex Builder update manager “
Cairngorm Plugin (0.0.6.200811131413) requires plug-in "org.eclipse.emf.codegen" ” as displayed in the image below
To resolve this, I selected the Europa Discovery Site from the wizard along with the Cairngorm plug-in option created by following the installation instructions. Then used the “Select required” button to install the needed eclipse plug-ins for codegen that are required by the Cairngorm plug-in. The images below display the “install” after all dependencies were resolved.
Pitfall 2: What are Cairngorm locations and how can I set one in my workspace?
Cairngorm location is a codegen templates files used by the plug-in code generation as the Controller, Command and Event templates. You can download them from this location and although they are specified as Cairngorm 2.2.2-Beta related I can see no reason why you can not use them with Cairngorm 2.2.1.
Unzip the file to a folder of your choice and follow the user manual from here note that the location is the directory created when you unzipped the file downloaded above. I was not fond with the original templates; I prefer using the ICommand and IResponser interfaces and wanted opening brackets to be on the end of line and not in the beginning of the next line. Editing the defaults was quite straight forward the format used by JET is very similar to the JSP (Java Server Pages) syntax.
Under the folder where you unzipped the files go to "resources\flexbuilder\templates\" and edit the “.asjet” files using your favorite text editor. If you need something complicate you can have look here.
Pitfall 3: No controller found under the project
This usually happens when you started using the plug-in after you already had your own controller in the project.
In order for the plug-in to identify your Controller you need to specify a UUID for it as described here under to Known Issues.
Pitfall 4: Cairngorm Controller and Cairngorm Command not appearing in pop-up menu
This is a known issue as well and can be found again here (wow reading the instructions can relay help). You need to recreate your workspace which his real bummer.