I played a little bit with Groovy and GroovyShell and noticed that you can easily pass your (java) variables to it. It means that you can pass your editor's document and process it with Groovy.
I created simple module for processing xml files. It is based on XPathEvaluator module. It adds a new window to Netbeans where you can write Groovy scripts.
Code for "Run Script" button looks like this:
Binding binding = new Binding(); binding.setVariable("doc", xmlDoc); binding.setVariable("output", jTextArea1); GroovyShell shell = new GroovyShell(binding); shell.evaluate(jEditorPane1.getText());
It binds xmlDoc, which is EditorCookie.getDocument(), to doc variable and evaluates the script which is in jEditorArea.
Maybe a Groovy could be a new way for extending Netbeans? Tell me what you think.