The controller

The IlpTableController class represents the controller module of the MVC architecture. It can be attached to a table view by using the following code.

How to attach a controller to the table view

IlpTableView tableView = new IlpTableView();
IlpTableController tableController = new IlpTableController();
tableView.setController(tableController);
Note that a controller is automatically attached to a table view when a table component is instantiated:
IlpTable tableComponent = new IlpTable();
IlpTableController controller = tableComponent.getController();
// tableComponent.getView().getController() == controller
When a controller is attached to a table view, the controller listens to the keyboard, mouse, and focus events that occur in the table and transfers them to the view interactor set to the controller.
Only one controller can be attached to a view at a time.
By default, the IlpTableController delegates event management to an IlpDefaultTableViewInteractor. However, you can specify another interactor by using the following code:
tableController.setViewInteractor(new MyInteractor());
When an interactor receives mouse events from the controller, it tries to recognize the associated user gestures. For example, when it receives an event MOUSE_PRESSED followed by an event MOUSE_RELEASED , the interactor recognizes the gesture BUTTON1_CLICKED . The set of basic gestures recognized by an interactor is defined in the class IlpGesture .
Interactors allow you to associate behavior with user gestures by means of Java™ actions. You can also associate actions with keyboard events.
The IlpDefaultViewInteractor manages the events received from the controller in the following way:
  • If the event is a keyboard event, it checks whether an action has been associated with this key. If so, it triggers the action.
  • If the event occurred in the header, it delegates the event management to the IlpDefaultTableHeaderInteractor set to the controller, if any.
  • If the event occurred on an IlpGraphic object or on a representation object, it delegates the event management to the IlpObjectInteractor set to the controller, if any.
  • It checks whether the event corresponds to the display of a pop-up menu. If so, and if a pop-up menu is set to this interactor, it will display the pop-up menu and stop.
  • It tries to recognize gestures from the event. When a gesture is recognized, it triggers the action associated with this gesture, if any.
The API of the IlpTableController also contains methods to sort the columns and filter the rows of the table view. See Table component services.