A Simple Scripting Enviroment for NetBeans
By chuk on Jun 29, 2006
Scripting languages are popular (probably an understatement). JavaSE 6 (aka Mustang) will have first-class support for scripting languages. There is already a project at scripting.dev.java.net that have quite a few scripting engines for Mustang.
NetBeans is a top notch IDE. However to extend NetBeans, you have to resort to writing modules. People may what to invest time and energy into a hack and slash project like my recent FIFA World Cup module (Go England!). NetBeans current has a project call Coyote
that adds scripting languages support. But from Coyote's website, there is no mention of scripting NetBeans itself. So I've decide to add support for scripting into NetBeans.
Bear in mind that this module is stricly experimental. There are a lot of concepts that are not fully developed. The idea of this scrpting module is to perform most NetBean stuff (eg. creating a Editor TopCompont) but not to the level of the OpenIDE API.
Still interested? Here is what you need to do:
- Download and install Mustang. I've only tested this with build 89 and on Solaris/Linux only. YMMW on Windows.
- Install the excellent NetBeans 5 and all the related patches or updates.
- Startup NetBeans in Mustang. This is essential. There are 2 ways of doing this: either change $NETBEANS_HOME/etc/netbeans.conf or use the --jdkhome switch. Since the module is experimental, I would also like to encourage you to use the --userdir switch as well.
- Install the script engine and window system module. The window system module is optional.
- Install the example scripts. You can unzip this in any directory. The test scripts are examples to get you started until proper documentation are available
Here are things you can try:
- Now go to to Tools -> Scripts and select any one of the .js script. Note: If you did not install window system module, then you will not be able to run window.js
- Exit NetBeans and restart it. Observe. Now exit NetBeans again
- actions - all scripts that are saved here will appear in Tools -> Scripts. If you have added new script to this directroy do a Tools -> Scripts -> Reload. Currently the engine does not go recursively into the directory.
- load - all scripts that are saved here will be loaded when NetBeans starts up. This allows you to register events, etc.
You can introduce new functionalities into the script enviroment by creating ScriptModule. See the source for details; look at windowscriptmodule project. I will \*TRY\* to document this, promise.
One module that I'm itching to do is Jackpot. Today if you want to develop Jackpot, you either use the Jackpot rule file or develop a NetBeans module. Nothing in between. Hopefully a Jackpot ScriptModule will solve this.
A word on WindowScriptModule. The idea of this module is to be able to manipulate NetBeans windows. Currently the module is in its primordial stage. The only functionality there is to create windows, and not correctly I might add (see bugs below).
- Adding script engine in the option pane does not work yet. I'm having some classloader issues. If you manage to debug it, let me know. Here is the Groovy engine to try (JAR1,JAR2).
- TopComponet is not opening properly viz. an Explorer TopComponent is opening up in the editor space. In fact \*ALL\* TopComponents are opening up in editor space. I think my problem is TopComponent singletons. I've basically commented out all the default code in findInstance() method and just return a new TopComponent each time. How do I create a non-singleton TopComponent?
Whao! this is already more than a minute! Send me your comments
Sundar tried my module and got the following error:
Unfortunately I'm using the beta release of Matisse. So you'll have to update Matisse to get this to work. Thanks Sundar.