Weblog Commenting and Trackback by HaloScan.com smspoonam@gmail.com: 06/07/06
|

Wednesday, June 07, 2006

Creating Eclipse plugins for the Flex Builder debugger

Is there a feature missing from the Flex Builder debugger that you really wish we had put in?

No? Right, move along then.

Oh, what’s that? Yes, there is such a feature? Well then, now is your chance for fame and glory. (Notice I didn’t say fortune. That part probably takes more work than just writing a plugin.)

There is bad news and good news. The bad news is, in this release we will not be publishing the Flex-specific debugger APIs that live inside Flex Builder. We just haven’t had time to clean them up and test them to the degree that we would be comfortable releasing them as documented, supported APIs.

But, the good news is, our lack of Flex-specific APIs is not as big a problem as it might sound like at first, because Eclipse itself has a very clean, well-documented set of APIs for accessing generic debugger-related functionality (variables, breakpoints, callstacks, etc.). And it turns out that the vast majority of stuff that you can think of putting into a Flex Builder debugger plugin is actually generic debugger stuff, not Flex-specific.

For example, using the Eclipse APIs, here are a few things you can easily do within your own Flex Builder plugin:

* given a string, evaluate it as an expression
* change the value of a variable
* set a breakpoint
* determine the current callstack
* programmatically invoke step-into, step-over, resume, terminate, etc.

Okay, so where to start? In future posts I will give some actual code samples, but for now, here are a few key starting points inside Eclipse:

* Much of the key stuff is in the Java package org.eclipse.debug.core.model — this includes IVariable, IValue, IThread, IStackFrame, IDebugTarget (a program being debugged), IProcess (a program that was launched with either Debug or Run), IBreakpoint, ILineBreakpoint, IExpression, IWatchExpression.
* Also, a common starting point for getting anything done is a call to org.eclipse.debug.core.DebugPlugin.getDefault(). From there, you can get to the IBreakpointManager, ILaunchManager (again, a “launch” is anything that you launched with either Debug or Run), and IExpressionManager; and add a debug event listener so your code is notified when something interesting happens.
* Finally, class org.eclipse.debug.ui.DebugUITools has some useful helper functions. In particular, DebugUITools.getDebugContext() is more important than its bland name implies. The “debug context” is whatever is selected in the Debug view, such as a particular stack frame. This ends up affecting lots of things, like which variables are shown in the Variables view, and how expressions are evaluated: Expressions are evaluated in the context of the current stack frame.

The online documentation for all the Eclipse debugger classes is here (scroll down to the org.eclipse.debug.* packages).

Finally, I want to warn you that learning how to write Eclipse plugins is a very time-consuming undertaking. Eclipse is extremely modular — there are design patterns everywhere you turn. And that’s a good thing, because it gives you tremendous power to plug into it at any level (if this weren’t the case, we wouldn’t have been able to create something like Flex Builder on top of it).

But the downside of this modularity is that it’s really hard to just plunge in and start creating useful code, because it can be very hard to figure out how to get from point A to point B. (An example: Early on, I tried to figure out the code path from “user double-clicks in the margin of a document” to “blue circle shows up indicating a breakpoint has been created.” Whoo boy.) It took me about a month of full-time development before the lightbulb in my head finally lit up and I “got” how everything fits together; I then began to find it much quicker to write code.





Let’s write a plugin for the Flex Builder debugger. This will be a simple panel called Expression Tracker, which is like the Expressions view except that it does not refresh its displayed values each time you step. Don’t expect anything useful or beautiful here; this is just a barely-functional sample with a pretty rotten UI. But it’s a start.

I should warn you that creating Eclipse plugins takes a large investment of effort to understand how they fit together.
Eclipse cruft

* You’ll need to be using the plugin-based version of Flex Builder rather than the standalone version. This means that first, you have to install Eclipse version 3.1.2 from http://www.eclipse.org. Then, you have to install the plugin version of Flex Builder:

Go to this link will help u ./.
http://www.morearty.com/blog/category/adobe/flash-flex-flexbuilder/

|

Free books from O'Reilly

LAFX June Adobe Software Bundle Raffle

How to request FREE books from O'Reilly for the LA Flash Library.

O'Reilly has offered to contribute books to our Flash Resource Library. We would like to open up this opportunity for all users to request titles that may interest them. Remember that our library is located at the Flash Factory in Venice and is accessible M - F 9-6 by all LAFLASH members.

LAFX will be raffling one Adobe software bundle in June. Eligibility for this raffle is based on both LA Flash event attendance and other member activities, such as writing book reviews and posting them on Amazon.com. You can post multiple book reviews and receive a raffle ticket for each one. You have until the June LAFX meeting to enter. Send links to your reviews to elliot@laflash.org.


Bundle info:
http://www.adobe.com/products/bundles/

Web Bundle
Adobe Creative Suite Premium
Combines full versions of:
Adobe Photoshop� CS2
Adobe Illustrator� CS2
Adobe InDesign� CS2
Adobe GoLive� CS2
Adobe Acrobat� 7.0 Professional
Version Cue� CS2
Adobe Bridge
Adobe Stock Photos
Macromedia Studio 8
Combines full versions of:
Dreamweaver� 8
Flash Professional 8
Fireworks� 8
Contribute™ 3
FlashPaper™ 2

Video Bundle
Adobe Production Studio Premium
Combines full versions of:
Adobe After Effects� 7.0 Professional
Adobe Premiere� Pro 2.0
Adobe Photoshop� CS2
Adobe Audition� 2.0
Adobe Encore� DVD 2.0
Adobe Illustrator� CS2
Adobe Dynamic Link
Adobe Bridge
Adobe Stock Photos
Macromedia Flash Professional 8

Design Bundle (IF YOU PICK THIS ONE, YOU WILL BE MADE REDUNDANT)
Adobe Creative Suite Premium
Combines full versions of:
Adobe Photoshop� CS2
Adobe Illustrator� CS2
Adobe InDesign� CS2
Adobe GoLive� CS2
Adobe Acrobat� 7.0 Professional
Version Cue� CS2
Adobe Bridge
Adobe Stock Photos
Macromedia Flash Professional 8

|

Adobe ZMZ team

ZMZ stands for Zaphod, Mistral and Zorn. These are code names for Adobe Flash Player 9, Flex 2.0 and Flex Builder 2.0 respectively.

Adobe Flex 2 and Flash Player 9 would be released soon, not sure of dates. I can understand the excitement building up in the team. They must be waiting for RTM (release to manufacture/manufacturing), more than that, they would wait for the reactions from developer community and customers.

I am also very excited and very happy to think that ZMZ would be out finally after so much of hard work. Though, I am no more there (in Adobe) to celebrate that moment but guys I would celebrate whenever I would use the product. It's fruit of your hard work, dedication and passion.

I thank every member of ZMZ team for their hard work, which would make life of millions of developers easy over the time. I also thank every member of developer community (Flexcoders, MMbeta, flashcoders et al) for their continuous knowledge sharing efforts which at the end of day helps product team to build a better product.

BTW! This release would be party time for everyone not only ZMZ team. As these product would change the way we have been working to build Rich Internet applications and other types of applications. You already know about new features but you would soon see the innovative usages once product is released.

|

Info on the Proxy

Some more airport blogging. I was going to write an article on the proxy, the part of Flex that is used by HTTPService and RemoteObject to access resources. I never found time to write much about this, though, and I don't see much time clearing up in the weeks ahead. Here's the notes I've jotted down for why you'd want to use the proxy:

1. To have a centralized whitelist or when crossdomain.xml can't be used.
2. When you need to have the text from errors. This doesn't show up without the proxy because the player isn't always given the text from the browser when there's an error status code.
3. When you want custom dialog boxes for security, since the proxy is the only way to do custom authentication/authorization.
4. And there's probably more reasons in 2.0. I don't know much about what's happening in the enterprise offering, but I do know the team has some amazing people on it who have been working like mad.

|

Communicate with the browser from Flex

If, for some reason, you need to communicate with the browser from Flex, you can use the ExternalInterface API. However, Adobe probably doesn't recommend this as a best practice. The following example opens a new browser window by clicking a button in a Flex application. One thing to keep in mind is that there are many different browsers currently in use. Any javascript functions that you create should be researched, to ensure that they are supported by the browsers that will view the application. Note: javascript that is inserted into the HTML wrapper file will be lost every time that the application is compiled, unless the "Project / Properties / Flex Compiler / Generate HTML wrapper file" option is turned off.

javascript: (insert into HTML wrapper file that Flex creates)