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; }
// 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);
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; }
// 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);
getHeaderInteractor
method of IlpTable. This interactor can be customized
in the same way as the interactor for the main view.
Table { interactor: true; } Interactor { viewInteractor: @+viewInt; } Subobject#viewInt { class: 'ilog.cpl.table.interactor.IlpDefaultTableViewInteractor'; popupMenuFactory: @+viewPopupMenuFactory; } Subobject#viewPopupMenuFactory { class: MyTableMenuFactory; }
public MyTableMenuFactory extends IlpAbstractPopupMenuFactory { public JPopupMenu createPopupMenu (IlpObjectSelectionModel ilpSelectionModel) { // The following menu could be context-dependent JPopupMenu popupMenu = new JPopupMenu(); // Create here the items and add them in the menu // .... return popupMenu; } }
IlpTable tableComponent = new IlpTable(); // Use a custom pop-up menu in the table view IlpPopupMenuFactory tableMenuFactory = new MyTableMenuFactory(); tableComponent.getViewInteractor().setPopupMenuFactory(tableMenuFactory); // Use the default header pop-up menu in the table header IlpPopupMenuFactory headerMenu = new IlpDefaultTableHeaderMenuFactory(); tableComponent.getHeaderInteractor().setPopupMenuFactory(headerMenu);