A Simple Scripting Enviroment for NetBeans

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:

  1. Download and install Mustang. I've only tested this with build 89 and on Solaris/Linux only. YMMW on Windows.
  2. Install the excellent NetBeans 5 and all the related patches or updates.
  3. 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.
  4. Install the script engine and window system module. The window system module is optional.
  5. 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 ;-)
So once you have installed the modules, go to Tools -> Options -> Miscellaneous -> Scripts and set the 'Script repository' field to the script directory that you've expanded.

Here are things you can try:
  1. 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
  2. Exit NetBeans and restart it. Observe. Now exit NetBeans again
Here is how the module works. The script engine module will look for 2 directory in its script repository directroy.
  1. 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.
  2. load - all scripts that are saved here will be loaded when NetBeans starts up. This allows you to register events, etc.
When you configure the script repository path, there is a check box that says 'Initialize script repository'. This creates the actions and load directory in you script repository. If you are starting a new repository, check this.
 
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).

Bugs
  1. 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).
  2. 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?
The realy irony here is that you cannot create scripts in NetBeans. NetBeans does not allow you to casually mount a directory and edit files (I miss the mount feature). The only script editor that I've found is a Javascript editor which you can find here. Hopefully I'll remedy this in the next version, providing a nicer user inerface. I need to use Nodes and stuff like that but I'm fairly new to NetBeans so I'm currently reading Tim Boudreau series of articles on this.

Whao! this is already more than a minute! Send me your comments

Oops!
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.

Comments:

Long, long time ago we had a project here: http://scripting.netbeans.org/ Not sure whether it still works. But it used to add scripting to NB. Died for lack of interest. Makes me smile to find out that after 4 years people keep coming with the same ideas we had back then. Good luck, David

Posted by David Strupl on June 29, 2006 at 08:42 AM SGT #

Hi Chuk: It worked after I updated with Matisse module from "NetBeans Update Center Beta"!

Posted by A. Sundararajan on June 29, 2006 at 10:40 AM SGT #

Post a Comment:
Comments are closed for this entry.
About

Random thought at random intervals

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today