| Graphic Components > Table Component > Table Component Services > Interacting with the Table View |
Interacting with the Table View |
INDEX
PREVIOUS
NEXT
|
The table component allows you to define behavior for the main view of the table, as well as specific behavior for the table header. In both cases, an interactor is used. The default interactors handle the basic interaction supported by the table (selection, moving columns, for example) and can be easily customized to:
A default view interactor (an instance of IlpDefaultTableViewInteractor) is associated with the main view of the table component. It is retrieved using the getViewInteractor method of IlpTable.
You can associate actions with mouse events by using either CSS or the API. The following CSS extract shows how to proceed:
Table {
interactor: true;
}
Interactor {
viewInteractor: @+viewInt;
}
Subobject#viewInt {
class: 'ilog.cpl.table.interactor.IlpDefaultTableViewInteractor';
action[0]: @+viewAction0;
}
Subobject#viewAction0 {
class: 'ilog.cpl.interactor.IlpGestureAction';
gesture: BUTTON1_DOUBLE_CLICKED;
action: @+myAction;
}
Subobject#myAction {
class: MyAction;
}
The same configuration can be achieved through the API, as follows:
// Create the table, and retrieve the view interactor IlpTable tableComponent = new IlpTable() IlpViewInteractor viewInteractor = tableComponent.getViewInteractor(); // Create a Swing action // We assume the MyAction class is defined elsewhere Action myAction = new MyAction(); // Double-clicking the left mouse button will trigger myAction viewInteractor.setGestureAction(IlpGesture.BUTTON1_DOUBLE_CLICKED, myAction);
.
| Note |
| A gesture is a series of one or more atomic user input events that are meant to invoke a single action. |
You can associate actions with keyboard events by using either CSS or the API. The following CSS extract shows how to proceed:
Table {
interactor: true;
}
Interactor {
viewInteractor: @+viewInt;
}
Subobject#viewInt {
class: 'ilog.cpl.table.interactor.IlpDefaultTableViewInteractor';
action[0]: @+viewAction0;
}
Subobject#viewAction0 {
class: 'ilog.cpl.interactor.IlpKeyStrokeAction';
keyStroke: 'ctrl typed D';
action: @+myAction;
}
Subobject#myAction {
class: MyAction;
}
The same configuration can be achieved through the API, as follows:
// Create an action
Action myAction = new MyAction();
// Typing CTRL+D will trigger myAction
KeyStroke ctrlD = KeyStroke.getKeyStroke('D',java.awt.Event.CTRL_MASK);
viewInteractor.setKeyStrokeAction(ctrlD, myAction);
Both mouse and keyboard actions can be invoked anywhere in the table, except in the header.
Usually, specific behavior is needed for the table header. For that reason, the table component also has a default interactor for the header. It is an instance of IlpDefaultTableHeaderInteractor and can be retrieved using the getHeaderInteractor method of IlpTable. This interactor can be customized in the same way as the interactor for the main view.
| Note |
| If no header interactor is set to the table controller (that it, if it is null), the events are handled directly by the view interactor. |
The JViews TGO interactors allow you to create custom pop-up menus easily for the table. To do this, you should implement the IlpPopupMenuFactory interface. One abstract and two default menu factories are provided, which you can extend by subclassing:
IlpAbstractPopupMenuFactory gives you easy access to the currently selected business objects.
IlpDefaultTableHeaderMenuFactory allows you to show or hide a column and change the sorting criterion of a column.
IlpDefaultTableMenuFactory allows you to fix columns and show the hidden columns.
The following code shows how to define a custom pop-up menu factory for the table view.
You can customize a pop-up menu factory for the table view or the table header, either through CSS or through the API. The following CSS extract shows how to configure a CSS file to add a pop-up menu factory:
Table {
interactor: true;
}
Interactor {
viewInteractor: @+viewInt;
}
Subobject#viewInt {
class: 'ilog.cpl.table.interactor.IlpDefaultTableViewInteractor';
popupMenuFactory: @+viewPopupMenuFactory;
}
Subobject#viewPopupMenuFactory {
class: MyTableMenuFactory;
}
The same configuration can be achieved through the API, as follows:
IlpAbstractPopupMenuFactory as follows:
Please refer to Interacting with the Graphic Components for a detailed description of interactors and gestures.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |