Thursday, February 16, 2006

Forgotten datatypes part 2....

It was just pointed out to me that many people many not know how to get the code for a custom renderer into an extension that SQL Developer will use. So here's the rest of the steps to getting your custom column renderer into SQL Developer.

The first thing which will be needed is an extensio.xml file to describe the extension.

<extension xmlns=""
<name>Example Custom Column Renderer</name>
<owner>Kris Rice</owner>
<jdeveloper-hook xmlns="">
<description>Example Column Display</description>

Now to stich it all together, here's the ant build file I used for this example. There's a few properties to setup the location of SQL Developer which will of course have to be changed per install. The extension.xml from above is use in the jar which created. The final step to getting this all to work is simply putting the produced jar file into the /jdev/extensions folder.

<project name="Custom Columns Renderer" default="deploy">
<target name="init">
<property name="sdev.home" value="../raptor/ide/" />
<property name="extension.filename" value="net.jokr.xmlcolumnrenderer.jar" />
<property name="built" value="build" />

<path id="compile.classpath">
<fileset dir="${sdev.home}/ide/lib" includes="*.jar" />
<fileset dir="${sdev.home}/jdbc/lib" includes="*.jar" />
<fileset dir="${sdev.home}/jdev/extensions" includes="oracle.onlinedb.jar" />
<fileset dir="${sdev.home}/jdev/extensions" includes="oracle.sqldeveloper.jar" />
<fileset dir="${sdev.home}/jdev/lib" includes="jdev.jar, ojc.jar, jdev-patch.jar" />

<target name="compile" depends="init"
description="Compile java code">
<delete dir="${built}/classes" />
<mkdir dir="${built}/classes" />
<javac classpathref="compile.classpath" destdir="${built}/classes"
source="1.5" target="1.5" debug="true" includeAntRuntime="false">
<src path="src" />

<target name="jar" depends="compile"
description="Create the extension jar">

<jar basedir="${built}/classes"
<zipfileset prefix="META-INF" dir="." includes="extension.xml" />

<target name="deploy" depends="jar"
description="Deploy into the ide extensions directory">
<copy file="${built}/${extension.filename}"
tofile="${sdev.home}/jdev/extensions/${extension.filename}" />


Wednesday, February 15, 2006

Forgotten datatypes

After seeing the Georaptor project, I figured SQL Developer could use a method for rendering custom datatypes. Here's a quick example of how this is now possible in EA4.

The first thing is to make a class which is an Addin which registers the custom renderer.

import oracle.dbtools.raptor.controls.cellrenderers.CellRenderingFactory;
import oracle.ide.Addin;
import oracle.sql.CLOB;

public class CustomColRendererAddin implements Addin{

public void initialize() {
// register the custom renderer
CellRenderingFactory.registerCellRenderer(CLOB.class, new CLOBRenderer());


Next the actual renderer. This is a very simple example. The ICellRenderer interface has 2 methods on it. The getComponent is called first. If nothing is returned from any of the registered addins the getText is called next and will just be used in the standard component.

import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import oracle.dbtools.raptor.controls.cellrenderers.ICellRenderer;
import oracle.sql.CLOB;

public class CLOBRenderer implements ICellRenderer {

public String getText(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
// if getComponent returns null
// get text will be called to get the text for to be placed in the
// default component
return null;

public Component getComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Component ret = null;
CLOB lob = (CLOB) value;
try {
JLabel l = new JLabel(lob.getSubString(1,20));
// the only real difference over the base renderer
// is the added tooltip
ret = l;
} catch (Exception e) {
return ret;


The end results....