Site Manager Developer Manual / Version 2207
Table Of ContentsA renderer is used to render the table cells of the document table view in the Explorer, Workflow, Query and ResourceChooser window.
Class to subclass
In order to create your own renderer class you need to subclass the abstract hox.corem.editor.toolkit.table.columnrenderer.LayoutColumnRenderer class and implement the following two methods:
getComponent
This method returns the
JComponent
which will be used for the table cell. The method is called without parameters.customizeComponent
This method is called with the
JComponent
returned fromgetComponent
and anObject
which contains the data to render. The actual object which will be passed to the method depends on the window for which the renderer is defined. In the Explorer window a ResourceHolder is passed and in the Workflow window a WfInstance is passed to the method.
Integrate your renderer into the Site Manager using
editor.xml
You can integrate your renderer into the Site Manager using the element
Renderer
which can be used within the element ColumnDefinition
. ColumnDefinition
can be
used within TableDefinition
which can be used within the elements Explorer, Query,
Workflow
and ResourceChooser
.
<Explorer name="configurable-explorer"> ... <TableDefinition> .. <ColumnDefinition class="StringColumn" name="" width="40" weight="0.0"> <Renderer class= "com.customer.example.editor.ConstantLayoutColumnRenderer"/> </ColumnDefinition> ... </TableDefinition> </Explorer>
Example 4.10. How to integrate a Renderer in the editor
Example
The following example shows a very simple renderer which inserts a JLabel
saying "Hello" in each cell
of the table column independent of the column type.
package com.customer.example.editor; import javax.swing.JComponent; import javax.swing.JLabel; import hox.corem.editor.toolkit.table.columnrenderer.LayoutColumnRenderer; public class ConstantLayoutColumnRenderer extends LayoutColumnRenderer { public JComponent getComponent() { return new JLabel(); } public void customizeComponent(JComponent component, Object data) { JLabel label = (JLabel)component; label.setOpaque(true); label.setText("Hello"); } }
Example 4.11. Example of a customized Renderer class
Why returning the JLabel
first and entering the text ("Hello") later? This is because
customizeComponent
will be called later, short before the rendering. It is good practice to execute
"expensive" operations at this place.