I am developing an RCP Application, and am using Nebula's NatTable for that. I configer row selection (use DefaultRowSelectionLayerConfiguration) , and configer cell button (use ButtonCellPainter) . the both ui bing left mouse down event.
What I want is:
When i click the left mouse button, the button responds to the event while the button of whole row is selected.
Below part code:
selectionLayer = new SelectionLayer(columnHideShowLayer,false);
selectionLayer.setSelectionModel(new RowSelectionModel<Row>(selectionLayer, bodyDataProvider,
new IRowIdAccessor<Row>() {
@Override
public Serializable getRowId(Row rowObject) {
return rowObject.getStatus();
}
}));
selectionLayer.addConfiguration(new DefaultRowSelectionLayerConfiguration());
class ButtonClickConfiguration<T> extends AbstractUiBindingConfiguration {
private final ButtonCellPainter buttonCellPainter;
public ButtonClickConfiguration(ButtonCellPainter buttonCellPainter) {
this.buttonCellPainter = buttonCellPainter;
}
@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
// Match a mouse event on the body, when the left button is clicked
// and the custom cell label is present
CellLabelMouseEventMatcher mouseEventMatcher = new CellLabelMouseEventMatcher(GridRegion.BODY,MouseEventMatcher.LEFT_BUTTON, CUSTOM_CELL_LABEL5);
// Inform the button painter of the click.
uiBindingRegistry.registerMouseDownBinding(mouseEventMatcher, this.buttonCellPainter);
}
}
I research source code , i find UiBindingRegistry this code:
private IMouseAction getMouseEventAction(MouseEventTypeEnum mouseEventType, MouseEvent event) {
// TODO: This code can be made more performant by mapping mouse bindings
// not only to the mouseEventType but
// also to the region that they are interested in. That way, given an
// area and an event we can narrow down the
// list of mouse bindings that need to be searched. -- Azubuko.Obele
try {
LinkedList<MouseBinding> mouseEventBindings = this.mouseBindingsMap
.get(mouseEventType);
if (mouseEventBindings != null) {
LabelStack regionLabels = this.natTable.getRegionLabelsByXY(event.x,
event.y);
for (MouseBinding mouseBinding : mouseEventBindings) {
if (mouseBinding.getMouseEventMatcher().matches(this.natTable,
event, regionLabels)) {
return mouseBinding.getAction();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
If MouseDown event bing two event, Only the first to be able to perform.What should I do? I can think of the way is to select a row of data at the same time simulation of a cell button press action, But I don't know how to simulate the action of cell button.
Any help is appreciated.
If you want multiple actions to be performed on one interaction, you need to create a custom action that executes the both desired actions together.
I showed this here for performing selection and menu opening. Showing NatTable context menu