Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Select column upon RMB click
Select column upon RMB click [message #890581] Fri, 22 June 2012 15:45 Go to next message
Rashmy A is currently offline Rashmy AFriend
Messages: 149
Registered: July 2009
Senior Member
Firstly congratulations on your move to Eclipse!! This is great!

Now to the question Smile
I'm trying to select the entire column when user does RMB click on one of the column header cells. This is to ensure that the user knows on what column the menu is going to be applied.

Currently only the left mouse click is registered to select the full column when user clicks on one of the header cells. The right mouse click is registered to open the popup menu.

To achieve my requirements, I created MyTestPopupMenuAction that extends from PopupMenuAction. Then attempted to fire a column selection command. But no column is selected since it fails the conversion within SelectColumnCommandHandler.

Could you please take a look at the code below and let know what additional conversions are required?
public class MyTestPopupMenuAction 
    extends PopupMenuAction
{
    @Override
    public void run( NatTable natTable, MouseEvent event )
    {
        NatEventData eventData = NatEventData.createInstanceFromEvent( event );
        int columnPosition = eventData.getColumnPosition();
        int rowPosition = eventData.getRowPosition();
        natTable.doCommand( new SelectColumnCommand( natTable,
                    columnPosition, rowPosition, false, false ) );

        super.run( natTable, event );
    }
}


With the above code, it fails in SelectColumnCommandHandler.doCommand() when it invokes command.convertToTargetLayer(selectionLayer)). It is not able to match the selection positions with target layer (which I sent in as nattable).

Thanks,
Rashmy



Re: Select column upon RMB click [message #891737 is a reply to message #890581] Mon, 25 June 2012 16:45 Go to previous messageGo to next message
Rashmy A is currently offline Rashmy AFriend
Messages: 149
Registered: July 2009
Senior Member
I got this to work by firing ViewportSelectColumnCommand. Is this OK?
public class MyTestPopupMenuAction 
    extends PopupMenuAction
{
    @Override
    public void run( NatTable natTable, MouseEvent event )
    {
        natTable.doCommand( new ViewportSelectColumnCommand( natTable,
                natTable.getColumnPositionByX( event.x ), false, false ) );
        
        super.run( natTable, event );
    }
}


Thanks
Re: Select column upon RMB click [message #891744 is a reply to message #890581] Mon, 25 June 2012 18:00 Go to previous messageGo to next message
Rashmy A is currently offline Rashmy AFriend
Messages: 149
Registered: July 2009
Senior Member
No Message Body
Re: Select column upon RMB click [message #891930 is a reply to message #891744] Tue, 26 June 2012 15:50 Go to previous message
Edwin Park is currently offline Edwin ParkFriend
Messages: 124
Registered: July 2009
Senior Member
Hi Rashmy,

Yes - ViewportSelectColumnCommand is what you want if you have a Viewport in your layer stack. This will properly convert the coordinates to the scrollable layer underneath the viewport.

Cheers,
Edwin


Previous Topic:Select column & RowSelectionModel
Next Topic:Using a different configuration gives a NullPointerException
Goto Forum:
  


Current Time: Fri Dec 19 15:24:14 GMT 2014

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

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