Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Drag the mouse to select multiple row headers to select multiple rows
Drag the mouse to select multiple row headers to select multiple rows [message #1834729] Tue, 17 November 2020 03:29 Go to next message
kevent smith is currently offline kevent smithFriend
Messages: 6
Registered: November 2020
Junior Member
Dear All,
I want to select multiple whole rows by dragging the mouse. What should I do? thank you!
Re: Drag the mouse to select multiple row headers to select multiple rows [message #1834738 is a reply to message #1834729] Tue, 17 November 2020 08:48 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 47
Registered: March 2020
Member
You need to register the corresponding ui bindings. If you in general want to implement full row selection you can have a look at our _5052_RowSelectionExample that exactly shows how to do this.

https://github.com/eclipse/nebula.widgets.nattable/blob/master/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_505_Selection/_5052_RowSelectionExample.java
Re: Drag the mouse to select multiple row headers to select multiple rows [message #1834800 is a reply to message #1834729] Wed, 18 November 2020 08:42 Go to previous messageGo to next message
kevent smith is currently offline kevent smithFriend
Messages: 6
Registered: November 2020
Junior Member
Thank you for your reply. I'm sorry that maybe I didn't express the topic clearly. I want to select multiple lines by dragging the mouse in the row header.
Re: Drag the mouse to select multiple row headers to select multiple rows [message #1834803 is a reply to message #1834800] Wed, 18 November 2020 09:26 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 47
Registered: March 2020
Member
Then you need to add a corresponding UI binding for drag operations to the row header. This could look like this:

        SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer, false);
        selectionLayer.addConfiguration(new DefaultSelectionLayerConfiguration());
        selectionLayer.addConfiguration(new AbstractUiBindingConfiguration() {

            @Override
            public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
                IDragMode dragMode = new CellSelectionDragMode() {
                    @Override
                    public void fireSelectionCommand(NatTable natTable, int columnPosition, int rowPosition, boolean shiftMask, boolean controlMask) {
                        int localRowPosition = LayerUtil.convertRowPosition(natTable, rowPosition, selectionLayer);
                        selectionLayer.selectRow(0, localRowPosition, shiftMask, controlMask);
                    }
                };

                uiBindingRegistry.registerFirstMouseDragMode(
                        MouseEventMatcher.rowHeaderLeftClick(SWT.NONE), dragMode);
                uiBindingRegistry.registerFirstMouseDragMode(
                        MouseEventMatcher.rowHeaderLeftClick(SWT.MOD2), dragMode);
                uiBindingRegistry.registerFirstMouseDragMode(
                        MouseEventMatcher.rowHeaderLeftClick(SWT.MOD1), dragMode);
                uiBindingRegistry.registerFirstMouseDragMode(
                        MouseEventMatcher.rowHeaderLeftClick(SWT.MOD2 | SWT.MOD1), dragMode);
            }
        });


Although I personally would prefer the creation of corresponding configurations and commandhandlers. But the coding style is up to you and I can't provide a complete clean solution in a forum.
Re: Drag the mouse to select multiple row headers to select multiple rows [message #1834848 is a reply to message #1834800] Thu, 19 November 2020 01:36 Go to previous message
kevent smith is currently offline kevent smithFriend
Messages: 6
Registered: November 2020
Junior Member
Thank you for your perfect answer!
Previous Topic:Unit Tests - Issues with timeout
Next Topic:Column widths - scaled / unscaled
Goto Forum:
  


Current Time: Fri Mar 29 04:34:56 GMT 2024

Powered by FUDForum. Page generated in 0.02491 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top