Resizable row/column headers in NatTable

2019-09-19 02:44发布

问题:

I have NatTable with column and row headers, and use CornerLayer for it. How to make row and column headers resizable like any other column or row?

回答1:

You need to register the necessary bindings to the header regions

gridLayer.addConfiguration(new AbstractUiBindingConfiguration() {

    @Override
    public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
        uiBindingRegistry.registerFirstMouseMoveBinding(
                new ColumnResizeEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, 0),
                new ColumnResizeCursorAction());

        uiBindingRegistry.registerFirstMouseDragMode(
                new ColumnResizeEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, 1),
                new ColumnResizeDragMode());

        uiBindingRegistry.registerFirstMouseMoveBinding(
                new RowResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 0),
                new RowResizeCursorAction());

        uiBindingRegistry.registerFirstMouseDragMode(
                new RowResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 1),
                new RowResizeDragMode());
    }
});