Skip to main content



      Home
Home » Eclipse Projects » NatTable » Select column upon RMB click
Select column upon RMB click [message #890581] Fri, 22 June 2012 11:45 Go to next message
Eclipse UserFriend
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 12:45 Go to previous messageGo to next message
Eclipse UserFriend
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 14:00 Go to previous messageGo to next message
Eclipse UserFriend
No Message Body
Re: Select column upon RMB click [message #891930 is a reply to message #891744] Tue, 26 June 2012 11:50 Go to previous message
Eclipse UserFriend
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:Welcome
Next Topic:Select column & RowSelectionModel
Goto Forum:
  


Current Time: Tue Jul 08 22:26:10 EDT 2025

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

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

Back to the top