Using custom pseudo-classes

JViews TGO allows you to create and register your own pseudo-classes for the objects displayed in graphic components. For more information about pseudo-classes, see Pseudo-classes and pseudo-elements.
All JViews TGO graphic components allow you to add and remove pseudo-classes dynamically for the objects represented in their graphic view. Pseudo-classes allow you to specify CSS properties according to the graphic view context. In the tree, network and equipment components, you can use the methods available in the corresponding graphic view to register and unregister pseudo-classes for a given representation object. For example:
  • public void addPseudoClass (IlpObject bo, String pseudo) : adds a given pseudo-class to the business object.
  • public void removePseudoClass (IlpObject bo, String pseudo) : removes a given pseudo-class from the business object.
These methods are available in each JViews TGO component: IlpNetwork, IlpEquipment and IlpTree.
In the table component, you can register and unregister pseudo-classes for each table cell by using the following methods of the IlpTable:
  • public void addPseudoClass (IlpObject bo, IlpAttribute a, String pseudo)
  • public void removePseudoClass (IlpObject bo, IlpAttribute a, String pseudo)
The following example shows you how to specify a new pseudo-class in the network component to highlight an object from the business class ServiceManagedObject :
object."ServiceManagedObject" {
        foreground: black;
        background: #00000000;
}
object."ServiceManagedObject":highlight {
        background: yellow;
}
This style sheet extract illustrates two selectors used to define the representation of objects of the class ServiceManagedObject in their normal state and with the pseudo-class highlight.
In your application, when you want to highlight the objects, you just have to add the given pseudo-class to the business object. For example:
IlpObject bo = dataSource.getObject("NE1");
networkComponent.addPseudoClass(bo, "highlight");
This example retrieves the business object identified as NE1 and highlights its graphic representation by adding a pseudo-class. The graphic representation of the object will be recomputed according to the new pseudo-classes and will match the corresponding selectors in your style sheets.
To revert to the object representation normal state, you just have to remove the previously added pseudo-class as follows:
view.removePseudoClass(bo, "highlight");
JViews TGO automatically handles pseudo-classes for selection and focus management. All you have to do is define your CSS selectors with the pseudo-classes " selected " and " focus ."