Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 11:32 Go to next message
Mohamed SADI is currently offline Mohamed SADIFriend
Messages: 38
Registered: December 2013
Member
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 12:06 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
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 15:44 Go to previous messageGo to next message
Mohamed SADI is currently offline Mohamed SADIFriend
Messages: 38
Registered: December 2013
Member
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 16:43 Go to previous messageGo to next message
Mohamed SADI is currently offline Mohamed SADIFriend
Messages: 38
Registered: December 2013
Member
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 17:02 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
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: Fri Apr 19 00:59:20 GMT 2024

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

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

Back to the top