Skip to main content
  • Log in
  • Manage Cookies
Eclipse Foundation
Download
  • Projects
  • Working Groups
  • Members
  • Community
    • Marketplace
    • Events
    • Planet Eclipse
    • Newsletter
    • Videos
    • Blogs
  • Participate
    • Report a Bug
    • Forums
    • Mailing Lists
    • Wiki
    • IRC
    • Research
  • Eclipse IDE
    • Download
    • Learn More
    • Documentation
    • Getting Started / Support
    • How to Contribute
    • IDE and Tools
    • Newcomer Forum
  • More
      • Community

      • Marketplace
      • Events
      • Planet Eclipse
      • Newsletter
      • Videos
      • Blogs
      • Participate

      • Report a Bug
      • Forums
      • Mailing Lists
      • Wiki
      • IRC
      • Research
      • Eclipse IDE

      • Download
      • Learn More
      • Documentation
      • Getting Started / Support
      • How to Contribute
      • IDE and Tools
      • Newcomer Forum
  1. Home
  2. Blogs
  3. Wayne Beaton's blog
  4. Scripting Eclipse RCP with JavaScript?!?

Scripting Eclipse RCP with JavaScript?!?

Thursday, March 2, 2006 - 00:50 by Wayne Beaton

Ward and I have been talking about mashups a lot lately. We both think that Eclipse RCP is a great vehicle for building mashups on the desktop (we don’t think that mashups should be exclusive to the web). I’ve managed to invoke a few web services and do some interesting things from within Eclipse, but thus far, everything has required a lot of Java programming.

Then I thought of Eclipse Monkey (Dash Project). Eclipse Monkey is the result of some work done by Bjorn and Ward to bring scripting to Eclipse. You can use Eclipse Monkey to do all sorts of things provided you have a rich enough set of DOMs. DOMs basically contribute functionality that manifest as variables you can access in your scripts. The DOMs themselves are pretty easy to create; making them do interesting things is the challenge. But if you build reasonably good DOMs, you can reuse the heck out of them.

Anyway, it occurred to me that Eclipse Monkey can be used to invoke web services and create views and just about anything else you can imagine if you provide the right set of DOMs. Why not use Eclipse Monkey to drive a mashup?

I spent the afternoon coding up a couple of DOMs:

The first DOM contributes a variable named “Flickr”. You can use this variable to search for photos on flickr.com by providing a search phrase. The method returns a bunch of objects containing data about the photos, including a title and enough information to find the actual image itself.

The second DOM contributes a “TableView”. This is an Eclipse view that contains a table. You can tell the table to add and remove columns (columns are moveable and resizeable). When you add a column, you provide a label for the column, what to display, and an initial width. The “what to display” is either the name of a JavaScript function or the name of a property. The function or property is used on each object in the table to compute what will be displayed for that object in the column.

You can create any number of these “TableViews”. When you “get” the TableView, you provide an id. If you ask for a TableView with the same id twice, you get the same instance back. Use a different id, and you get a different TableView.

The third DOM contributes an “ImageViewer”. It listens to the workbench’s selection service and when the selection changes, it asks the selected object for an image to display. Currently, if the selected object has a “getImageUrl” method, it is invoked, and the resulting URL is used to download the image which is displayed. At some point, I’ll probably add the ability to provide the view with a JavaScript function to invoke on the object to get the image. I leveraged the Image View plugin I wrote about a few days ago for this so it displays a scaled version that gets enlarged when you hover over it.

Each of these DOMs is completely decoupled from the others. Everything is completely reusable.

Here’s a script that I wrote to test this out:


/*
* Menu: Fun
* DOM: http://needanupdatesite/org.eclipse.monkey.flickr
* DOM: http://needanupdatesite/org.eclipse.monkey.console
* DOM: http://needanupdatesite/org.eclipse.monkey.table
* DOM: http://needanupdatesite/org.eclipse.monkey.image
*/

function main() {
ImageView.show();
table = Table.getTable("photos");
table.clearColumns();
table.setName("Photos of Wayne");
table.addColumn("Id", "id", 100);
table.addColumn("Title", getTitle, 200);
table.addColumn("URL", "imageUrl", 200);
images = Flickr.search("Wayne");
table.setContents(images);
}

function getTitle(object) {
return object.title;
}

and here’s what it produces:

This is running in Eclipse 3.2M4. You can see the TableView open in the bottom right corner, displaying the results of searching Flickr. The image view (bottom left) displays the image corresponding to the object selected in the table. When you change your selection, the image changes.

There’s still a lot of work to do to make this really useful. Each of the DOMs is pretty simple and each basically does what I need it to do and little more. I’m going to spend some time making a little more useful (like make the table sortable on all columns). Also, this isn’t really much of a mashup yet since I’m only using one service. Now that I’ve proven that this works, I need to make DOMs for more services and work out how to actually mash things together…

And then, of course, I have to sort out how to package this all up in an Eclipse RCP application. I have some thoughts about this that I’m going to explore over the next couple of days. When I get this sorted out, it will be possible to create an Eclipse RCP using JavaScript. Maybe that will open the doors for other scripting languages…

Tags: 
Uncategorized
Source: 
https://waynebeaton.wordpress.com/2006/03/02/scripting-eclipse-rcp-with-javascript/
  • Wayne Beaton's blog
  • Sign in to post comments.

Eclipse Foundation Blogs

  • Ian Skerrett (857 posts)
  • Wayne Beaton (796 posts)
  • Mike Milinkovich (286 posts)
  • Benjamin Cabé (131 posts)
  • Ivar Grimstad (97 posts)
  • Tanja Obradovic (38 posts)
  • Thabang Mashologu (31 posts)
  • Christopher Guindon (15 posts)
  • Roxanne Joncas (14 posts)
  • Paul Buck (11 posts)
  • Frédéric Desbiens (11 posts)
  • Mikaël Barbero (9 posts)
  • Jameka Woodberry (9 posts)
  • Hudson Kelly (8 posts)
  • Brian King (6 posts)
  • Denis Roy (5 posts)
  • Gabriela Motroc (4 posts)
  • Shabnam Mayel (3 posts)
  • Gael Blondelle (3 posts)
  • Sharon Corbett (1 posts)
  • Shanda Giacomoni (1 posts)
  • Paul White (1 posts)
  • Jacob Harris (1 posts)
  • Stephanie Swart (1 posts)
  • Michael Plagge (1 posts)

Recent blog posts

  • Member Case Study: itemis Builds Its Automotive Industry Business
  • Why I’m Running for the OSI Board of Directors
  • Welcome jadeva GmbH to the Jakarta EE Working Group!
  • Credentials leaked on GitHub
  • Hashtag Jakarta EE #61
  • Eclipse Cloud DevTools Community Update - February 2021
  • Hashtag Jakarta EE #60
  • The 2021 Eclipse Community Newsletter Calendar
  • Hashtag Jakarta EE #59
  • Jakarta EE Marketing and Branding Committee Levels-Up with New Members
More

Eclipse Foundation

  • About Us
  • Contact Us
  • Donate
  • Members
  • Governance
  • Code of Conduct
  • Logo and Artwork
  • Board of Directors

Legal

  • Privacy Policy
  • Terms of Use
  • Copyright Agent
  • Eclipse Public License
  • Legal Resources

Useful Links

  • Report a Bug
  • Documentation
  • How to Contribute
  • Mailing Lists
  • Forums
  • Marketplace

Other

  • IDE and Tools
  • Projects
  • Working Groups
  • Research@Eclipse
  • Report a Vulnerability
  • Service Status

Copyright © Eclipse Foundation. All Rights Reserved.

Back to the top