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
l.setToolTipText(lob.getSubString(1,1000));
ret = l;
} catch (Exception e) {
e.printStackTrace();
}
return ret;
}
}
The end results....