I hinted at a project to develop a simple filter add-in in my last post on Code Generation with JDeveloper. So that turned into my latest weekend project;-)

I'm registering the project on sourceforge, but in the meantime you can get the full source kit here, or if you prefer just the add-in jar here (which just needs to be dropped into your ${jdev.home}/jdev/extensions folder). [30-Jan-2008: the project is now available on sourceforge] What does it do? It is a simple idea. Allow you to invoke an external program to filter any text you have selected in the JDeveloper Editor. Of course, it is up to you to define what filter means - limited by your imagination only. And by externalizing the filter process, it means you can use the tool or scripting language of your choice to implement and make on-the-fly changes to your filter. To be precise, the filter operates like operating system pipes: • Selected text is sent to the standard-input of the filter process. • The standard-output of the filter process is written back to replace the selected text. Configuring the Filter Configuration is done via the JDeveloper Tools | Preferences menu, and is very simple at present. It only supports a single filter process definition. As you can see in the screenshot, you just need to enter a valid command line to invoke the filter. A nice enhancement would be the support for multiple filter definitions. This is where the flexibility comes in. As an example, I've provided a rot13 encoder written in ruby [samples/myrot13filter.rb in the source kit]. puts$stdin.readlines.to_s.tr("A-Za-z", "N-ZA-Mn-za-m")

Ruby, Perl, php, vbscript/WSH, bash ... use whatever you prefer. Rather than needing to develop and deploy an add-in in Java, you can just script the filter.

Applying the filter is simply a matter of selecting some text in the IDE, and choose the Custom Text Filter item from the right-click pop-up menu

The Development View
The truth is that I developed this add-in as more an investigation of the Extensions SDK, and the filter idea appeared to be unexplored territory.

As Brian Duff writes, there are some major improvements in the support for JDeveloper Extensions in 11g. Since it is still in preview, I decided to stick with Extension SDK 10.1.3 however.

There are four classes of significance. since this was an educational exercise, I spent a bit of time to make sure I really understood how it all worked, and tried to reflect that with liberal comments in the source.
• CodePaneAddin - implements the pop-up menu hook and applies the filter
• ExecShell - wraps the invocation of the filter process iwth stdin/out handling. It is independent of the extension API and may be of interest in its own right
• ConfigPanelData - handles preferences panel configuration
• ConfigData - bean to wrap the configuration data

The source kit comes with a JDeveloper project and also ant build file. If you want to build and deploy the add-in to JDeveloper, simplest is to first check the environment-specific settings in build.properties and then simply run
C:\MyDocs\MyDev2\JDevFilter>ant deploy
Buildfile: build.xml

init:

prepare:

compile:

jar:

deploy:
[copy] Copying 1 file to C:\oracle\jdevstudio10131\jdev\extensions

BUILD SUCCESSFUL
Total time: 0 seconds

### Jupiter

 Ben Bova's Jupiter has me hooked on a new rack in the sci-fi bookshelf.I've always liked the hard-science of Asimov, and find myself frequently revisiting classics like The Naked Sun. It was not until Jupiter that I've found anything close.Now I'm just slow of course - for a long time I've been vaguely aware of the name Ben Bova and the respect he holds in scifi circles, but have failed to seek him out.Jupiter is the tale of Grant Archer's conscriptment to serve as a graduate student on the planetary research station orbiting Jupiter, and his secret mission forced on upon him to spy for the fundamentalist religious groups that have political power in their grip back on earth. In all its intriguing detail of the efforts to explore the planet Jupitor, the real story is the exploration of the relationship - and often conflict - between scientific inquiry and religion.I am sure the first of many Ben Bova novels I will read.The rash assertion that "God made man in His own image" is ticking like a time bomb at the foundation of many faiths. - Arthur C. Clarke