Skip to main content



      Home
Home » Eclipse Projects » NatTable » get the selected object when double click on Nattable cell
get the selected object when double click on Nattable cell [message #1384197] Wed, 28 May 2014 07:32 Go to next message
Eclipse UserFriend
Hello,

How can i get the selected object when i double click (Mouse Event) on nattable ?

i've tried to applly your suggestion in this topic :

http://www.eclipse.org/forums/index.php/t/441881/

but it's not working on nattable 1.1.0.
Re: get the selected object when double click on Nattable cell [message #1384209 is a reply to message #1384197] Wed, 28 May 2014 08:06 Go to previous messageGo to next message
Eclipse UserFriend
1. What is not working?
2. Why doesn't it work?
3. Where do you want to achieve what?

If you want to trigger an action in NatTable, try to register a IMouseAction for a double click MouseEventMatcher. If you want to implement a listener outside the NatTable scope, you will need to get the object via coordinates in the mouse event using natTable.getRowIndexByPosition(). This is how the actions in NatTable work for example.
Re: get the selected object when double click on Nattable cell [message #1384280 is a reply to message #1384209] Wed, 28 May 2014 11:44 Go to previous messageGo to next message
Eclipse UserFriend
I have a compilation error :
public void mouseDoubleClick(MouseEvent e) {
	//get the row position for the click in the NatTable
	int rowPos = natTable.getRowPositionByY(e.y);
	//transform the NatTable row position to the row position of the body layer stack
	int bodyRowPos = LayerUtil.convertRowPosition(natTable, rowPos, gridLayer.getBodyLayer());
	Currencycodedata ccd = bodyDataProvider.getRowObject(bodyRowPos);
	//Do something with ccd
}


Exactly this line : int bodyRowPos = LayerUtil.convertRowPosition(natTable, rowPos, gridLayer.getBodyLayer());

compilation error : Quote:
The method convertRowPosition(ILayer, int, IUniqueIndexLayer) in the type LayerUtil is not applicable for the arguments (NatTable, int, ILayer)
Re: get the selected object when double click on Nattable cell [message #1384295 is a reply to message #1384280] Wed, 28 May 2014 12:43 Go to previous messageGo to next message
Eclipse UserFriend
This is the whole code :
nattable.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseUp(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseDown(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseDoubleClick(MouseEvent e) {
				//get the row position for the click in the NatTable
				int rowPos = nattable.getRowPositionByY(e.y);
				//transform the NatTable row position to the row position of the body layer stack
				int bodyRowPos = LayerUtil.convertRowPosition(nattable, rowPos, gridLayer.getBodyLayer());
//				Currencycodedata ccd = bodyDataProvider.getRowObject(bodyRowPos);
				//Do something with ccd
			}
		});



Re: get the selected object when double click on Nattable cell [message #1384301 is a reply to message #1384295] Wed, 28 May 2014 13:02 Go to previous message
Eclipse UserFriend
Well then solve the compilation error. Looks like your body layer is no unique index layer.
Previous Topic:How to set background image for whole nattable
Next Topic:How to efficient upadate the whole data of a NatTable?
Goto Forum:
  


Current Time: Sat Jul 12 09:54:23 EDT 2025

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

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

Back to the top