| Styling > Using Cascading Style Sheets > Customizing Table Cells |
Customizing Table Cells |
INDEX
PREVIOUS
NEXT
|
The default table cell renderer (ilog.cpl.table.IlpTableCellRenderer) generates two default types of graphic representations for table cells:
IltNetworkElement class are represented as follows in the table:
IltLink class are represented as follows in the table:
IltShelf class are represented as follows in the table:
IltCard class are represented as follows in the table. (Objects of classes IltPort and IltLed differ only by the icon in the column "Object.")
Objects of class IltAlarm are represented as follows in the table:
Both of these representations can be customized through the use of style sheets.
The following table lists the properties involved in the table cell rendering.
In the case of predefined business objects for managed objects, an Object column displays the value of the attribute graphicRepresentation. It shows the tiny representation of the business object displayed in the table row. To customize this tiny representation, you can use the same CSS properties as for the symbolic representation of the specific predefined business class (for example, foreground, background, label, labelPosition). The following code extract:
object."ilog.tgo.model.IltNetworkElement" {
foreground: green;
}
changes the foreground color used in the tiny representation of network elements.
For a list of the properties that you can customize per type of predefined business object, please refer to the following sections:
This use case shows you how to customize the cells of the table. The CSS selectors used to customize the table cells are formed by the CSS type object and the CSS class <business class name/attribute name>, as illustrated in the following example.
This example is based on the CSS file located in
<installdir>/samples/table/styling/data/table.css
where <installdir> is the directory where you have installed JViews TGO.
object."Alarm/perceivedSeverity"[perceivedSeverity=0] {
labelBackground: '#FFFFFF';
label: Cleared;
toolTipText: "Cleared alarm";
}
object."Alarm/perceivedSeverity"[perceivedSeverity=1] {
labelBackground: '#C0C0C0';
label: Indeterminate;
toolTipText: "Indeterminate alarm";
}
The example illustrates a table cell configuration based on the value of the attribute perceivedSeverity.
By means of cascading style sheets, you can also customize the table cell representation according to the focus and selection states. To do so, you use the pseudoclasses focus and selected, as follows:
object."ilog.tgo.model.IltObject/name":selected {
labelForeground: red;
}
object."ilog.tgo.model.IltObject/name":focus {
labelForeground: blue;
}
object."ilog.tgo.model.IltObject/name" {
labelForeground: black;
}
This use case shows you how to customize multiple cells of a table. The CSS selectors used to customize the table cells are formed by the CSS type object and the CSS class <business class name/attribute name>, as illustrated in the previous example. However, you can use the * wildcard to indicate that multiple attributes of a given business class should be configured using a single selector.
The following example illustrates how you can configure all cells of business class ilog.tgo.model.IltNetworkElement to have a blue background:
object."ilog.tgo.model.IltNetworkElement/*" {
labelBackground: blue;
}
You can also specify that all columns related to alarms should have a bold font:
object."ilog.tgo.model.IltObject/*larm*" {
labelFont: "arial-bold-12";
}
Finally, the following CSS extract can be found in <installdir>/samples/table/styling/data/table.css, where <installdir> is the directory where you have installed JViews TGO. This CSS extract configures the background of all the cells in the rows displaying objects of the business class Alarm according to the value of the perceivedSeverity attribute.
object."Alarm/*"[perceivedSeverity] {
labelBackground: '@|valuemap(@=perceivedSeverityBackgroundMap, @perceivedSeverity)';
}
object."Alarm/*"[perceivedSeverity]:selected {
labelBackground: '@|valuemap(@=perceivedSeveritySelectionBackgroundMap, @perceivedSeverity)';
}
To further customize the table cell rendering, you may also:
IlvGraphic to generate an arbitrarily complex graphic representation (IlvCompositeGraphic). For more information about composite graphics, see Graphic Objects.
JComponent to generate a graphic representation and customize it using CSS.
TableCellRenderer interface) to generate an arbitrary Swing Component.
IlvGraphic instances can be used to represent table cells through the property 'class'. The given class must follow the JavaBeans pattern; its properties can be directly customized in CSS.
The following example illustrates the use of IlvGeneralNode to represent table cells:
object."Service/type" {
class: 'ilog.views.sdm.graphic.IlvGeneralNode';
label: @name;
labelPosition: Right;
labelColor: black;
labelSpacing: 4;
shapeType: RECTANGLE;
shapeWidth: 12;
shapeHeight: 12;
}
object."Service/type":selected {
labelColor: red;
}
For information about how to use JavaBeans in CSS and how to use the class property, refer to Class Property.
JComponent instances can be used to represent table cells in the same way as they are used to represent tree nodes (see How to Use a JComponent to Generate a Tree Node Representation).
In the following example, table cells are represented using a simple JLabel whose properties text, icon and foreground are customized according to the business attribute and the selection state of the table cell.
object."Service/type" {
class: 'javax.swing.JLabel';
icon : @=icon;
text: @type;
foreground: black;
}
object."Service/type":selected {
foreground: red;
}
Subobject#icon {
class: 'javax.swing.ImageIcon';
image: '@|image("service.png")';
}
As illustrated in this example, JComponent instances can be used to represent table cells through the property 'class'. The given class must follow the JavaBeans pattern; its properties can be customized directly in CSS (icon, text, foreground).
For information about how to use JavaBeans in CSS and how to use the class property, refer to Class Property.
You may want to replace the JViews TGO table cell representation by your own representation. To do so, you need to create your own implementation of the Swing TableCellRenderer interface. For details, refer to Using an Arbitrary TableCellRenderer in the Graphic Components documentation.
You will then be able to register the new table cell renderer in the table component through CSS or through the API.
For information on how to set a new table cell renderer through CSS, refer to The View Rule in the Graphic Components documentation.
For information on how to set a new table cell renderer through the API, refer to Configuring the Table Component through the API in the Graphic Components documentation.
You can improve the rendering performance of predefined business objects by replacing their graphic representation with a static image.
The graphicRepresentation attribute of predefined business objects can be configured with the useDefaultCellRenderer CSS property so that predefined business objects are rendered as static images in the table component. This technique will improve performance as static images are faster to render than the alarm colored tiny representation of predefined objects.
The following CSS example configures all ilog.tgo.model.IltObject business objects to be represented by the image myImage.png:
object."ilog.tgo.model.IltObject/graphicRepresentation" {
useDefaultCellRenderer: true;
icon: '@|image("resource/myImage.png")';
iconVisible: true;
}
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |