A powerful function…

Many have downloaded, looked at, and have commented on the source code for the attachment viewer project but some may not be aware of a powerful function the SWT Browser brings to the table.  As described in a past post about the architecture, the line where the browser is connected with the embedded browser process (its actually a dotted line) is where this call happens.  The function, or method, is the execute method on the SWT browser.  This allows you to run essentially any JavaScript on a given web page or DOM.  The attachment viewer uses this method to call a JavaScript function named “showAttachments()”.  The Eclipse Java code takes the current selection – which in this case it looks for IAttachment – and then passes a set of URL’s and JSON to that JavaScript function.   This is how easy it is to “connect” the web world with the Eclipse world.

String cmd = "showAttachments(" + jObj.toString() + ");";
 if (browser.execute(cmd) == false){

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s