Interacting with the table cells

The topic Interacting with the table view describes how to set an interactor for the entire table view. You can also associate behavior with business objects (for a class or for individual objects), as well as with individual table cell instances. To do so, you use object interactors, which provide the same options as the view interactor, that is:
  • Associating actions with mouse events
  • Associating actions with keyboard events
  • Defining a pop-up menu factory to build a pop-up menu that displays on representation objects
The object interactor handles any events occurring on the object with which the interactor is associated, provided the view interactor has enabled the use of object interactors. You can check this by means of the isUsingObjectInteractor method or modify it with the setUsingObjectInteractor method. Object interactors are enabled by default.
No default interactor is associated with any object. To associate actions with mouse or keyboard events or to define a pop-up menu factory, you first have to create an IlpObjectInteractor. You may use the IlpDefaultObjectInteractor, extend it, or create your own implementation.

How to associate an object interactor with a representation object in the table

You can associate an object interactor with a representation object by using either CSS or the API. The following CSS extract shows how to proceed:
Table {
  interactor: true;
}

object."ilog.tgo.model.IltNetworkElement" {
  interactor: @+objInteractor;
}
Subobject#objInteractor {
  class: 'ilog.cpl.interactor.IlpDefaultObjectInteractor';
}
The same configuration can be achieved through the API, as follows:
IlpTable table = // ... 
IltNetworkElement ne = //... 
IlpTableController tableController = table.getController();
// Create an object interactor
IlpObjectInteractor objectInteractor = new IlpDefaultObjectInteractor();
tableController.setObjectInteractor(ne, objectInteractor);
// Configuring the specific object interactor is similar to configuring 
// a view interactor. 
objectInteractor.setGestureAction(IlpGesture.BUTTON3_CLICKED, new MyAction());

How to associate an object interactor with a table cell

You can associate an object interactor with a table cell, which is identified by a representation object and an attribute, by using either CSS or the API. The following CSS extract shows how to customize a specific object interactor to the cell that represents the name attribute:
Table {
   interactor: true;
}
object."ilog.tgo.model.IltNetworkElement/name" {
   interactor: @+objInteractor;
}
Subobject#objInteractor {
   class: 'ilog.cpl.interactor.IlpDefaultObjectInteractor';
}
The same configuration can be achieved through the API, as follows:
IlpTable table = // ...
IltNetworkElement ne = //...
IlpAttribute attribute = IltNetworkElement.NameAttribute;
IlpTableController tableController = table.getController();
// Create an object interactor
IlpObjectInteractor objectInteractor = new IlpDefaultObjectInteractor();
tableController.setObjectInteractor( ne, attribute, objectInteractor);
Actions related to mouse and keyboard events can be customized in the same way as for the view interactor. A pop-up menu factory can also be defined in the same way as for the view interactor. Refer to Interacting with the table view.
For a detailed description of interactors and gestures, refer to Interacting with the graphic components .