Interacting with the network objects

The topic Interacting with the network view describes how to set an interactor on the entire network view. You can also associate behavior with business objects (a whole class or individual objects), as well as with individual object instances.
To do so, you use object interactors, which offer you the same possibilities as the view interactor:
  • 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
An object interactor handles any event occurring to the object with which it is associated, provided the view interactor has enabled the use of object interactors. You can check this with 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 instance of IlpObjectInteractor. You can use the IlpDefaultObjectInteractor class, extend it, or create your own implementation.

How to associate an object interactor with a network component object

You can associate an object interactor with a representation object by using either CSS or the API.
The following extract shows how to proceed in CSS:
Network {
  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:
IlpNetwork network = // ...
IlpNetworkController networkController = network.getController();
// Create an object interactor
IlpObjectInteractor objectInteractor = new IlpDefaultObjectInteractor();
networkController.setObjectInteractor( bo, objectInteractor);
// Configuring the specific object interactor is similar to configuring 
// a view interactor. 
objectInteractor.setGestureAction(IlpGesture.BUTTON3_CLICKED, new MyAction()); 
Actions related to mouse and keyboard events can be customized in the same way as for the view interactor. You can also define a pop-up menu factory in the same way as for the view interactor. Refer to Interacting with the network view.
An object interactor can also be associated with a specific decoration that is part of the business object graphic representation in the network view. Each decoration represents a business attribute in the model. Therefore the customization of the interactor for a specific decoration takes into account the business object and a business attribute as illustrated below:

How to associate an object interactor with the label decoration in a network component object

You can associate an object interactor with one of the graphic decorations of the object by setting the interactor to the business attribute that is represented. You can do it using CSS or the API.
The following extract shows how to proceed in CSS:
Network {
  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:
IlpNetwork network = // ...
IlpNetworkController networkController = network.getController();
// Create an object interactor
IlpObjectInteractor objectInteractor = new IlpDefaultObjectInteractor();
networkController.setObjectInteractor( bo, IltObject.NameAttribute, 
objectInteractor);
// Configuring the specific object interactor is similar to configuring 
// a view interactor. 
objectInteractor.setGestureAction(IlpGesture.BUTTON3_CLICKED,   new 
MyAction()); 
Actions related to mouse and keyboard events can be customized in the same way as for the view interactor. You can also define a pop-up menu factory in the same way as for the view interactor. Refer to Interacting with the network view.
For a detailed description of interactors and gestures, refer to Interacting with the graphic components.