06 August, 2006

My First Eclipse Monkey Script

My mother must be so proud...

The following bit of javascript will search the current workspace for projects that are locally modified subversion resources. In other words, they're checked in to subversion, but need committing. It doesn't do much with the results except to present a dialog box. I'll show you later what you can do with that list.

To install the script, first you have to have Eclipse Monkey installed. Once you've got that set up: copy the javascript below, including the jabberwocky quote surrounding it, into the clipboard. Then, in eclipse, select the menu item "Monkey->Paste New Script" and away you go. The script will appear in the Monkey menu. Enjoy!

--- Came wiffling through the eclipsey wood ---
/*
 * Menu: Versions > Find Modified Projects
 * Kudos: Toby Tripp
 * License: EPL 1.0
 *
 * The Update Site URL and Feature ID of the "DOM" for this script:
 * DOM: http://tripp.no-ip.org/eclipse/updates/com.ttripp.eclipsemonkey.doms
 *
 * Note that this DOM depends on the Subclipse plug-in:
 *   http://subclipse.tigris.org/update_1.2.x
 */
 
 
 function main() {
  
  var dirtyProjects = svn.dirtyProjects();
  text = "\"Dirty\" Projects: (" + dirtyProjects.length + ")\n";
  
  for each( project in dirtyProjects ) {
   
   text += project.getIResource().getName() + "\n";
  }
  
  Packages.org.eclipse.jface.dialogs.MessageDialog.openInformation(  
        window.getShell(),  
        "Monkey Dialog", 
        text
     )
 }
 
--- And burbled as it ran! ---

No comments: