Saturday, May 7, 2011

How to add custom Quick Assist options to FlashBuilder 4.5 ?

Adding custom quick assist options to FlashBuilder 4.5.1 is easy.

Here is a sample plugin I created to show how this can be done. Copy this plugin into the dropins folder found under the "Adobe FlashBuilder 4.5" folder of the installation. In FB pressing Ctrl+1 inside a ActionScript class or script block of MXML file should bring up the "Override/Implment Methods" quick assist option as shown below.

One needs to implement the "com.adobe.flexbuilder.as.editor.quickAssistProvider" extension point to add custom quick assist providers in a custom plugin. The extension point requires the IQuickAssistProvider interface to be implemented by a class and supply this as a "class" value to the extension point description.

Step by step instructions on how to do this:

1. Create a new workspace and import the following plugins from FlashBuilder plugins folder. (These are the basic plugins which are required for the example. You may need to import more plugins based on the exact quick assist you want to implement.)

com.adobe.flash.codemodel.core

com.adobe.flexbuilder.as.editor

com.adobe.flexbuilder.codemodel

com.adobe.flexbuilder.editorcore

com.adobe.flexbuilder.editors.derived

com.adobe.flexide.as.core

com.adobe.flexide.editorcore

2. Create a new plugin called say "com.adobe.flashbuilder.extras"

3. Add the extension point "com.adobe.flexbuilder.as.editor.quickAssistProvider"

4. Create a class implementing the interface IQuickAssistProvider by clicking the class link. Add the necessary code for the required functionality in the class following the example source given.

The interface has only one method getProposals which needs to return a list of proposals that need to be displayed at the particular offset at which the user has invoked the quick assist. Using the information available in the IQuickAssistInvocationContext and other code model APIs the code can arrive at this list.

5. Export the new plugin and place the jar in the dropins folder under the FB installation.

Caution : In case you find that quick assist functionality of FB stops working check the logs to see if the new plugin is causing any exceptions causing this.

The example source is available here.

4 comments:

dineshkumar said...

Hi Sreenivas ,
I am dinesh .I need your kind help regarding the FB plugin.I am developing an plugin where it adds the code to the model.I am able to add attributes to components and containers but not able to add to this .Can you please help me.My development has stopped with this and i am not able to proceed also not getting examples.my id dineshkumar.tm@gmail.com

Thanks,
Dinesh

dineshkumar said...

Hi Sreenivas ,
I am dinesh .I need your kind help regarding the FB plugin.I am developing an plugin where it adds the code to the model.I am able to add attributes to components and containers but not able to add to this .Can you please help me.My development has stopped with this and i am not able to proceed also not getting examples.my id dineshkumar.tm@gmail.com

Thanks,
Dinesh

dineshkumar said...

hi here i meant this as mx:object tag..

Thom Whu said...

Hi, I am Thom. I try it in the FlashBuilder 4.6, But it dose not work. I just want to develop flex use code_behind pattern. Generating the componnets' event handler in the as file. Could you help me realize it. Thank you, email: moushuai00@hotmail.com