Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Enable Eclipse commands based on selections within NatTable
Enable Eclipse commands based on selections within NatTable [message #898776] Fri, 27 July 2012 14:11 Go to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
Hello,
If we have a Eclipse table, we have the support to enable/disable a toolbar command based on selections within the table since these selections are sent to my command's property tester. I would like to hook up similar capability with NatTable. Could you please suggest how I can send a call to evaluate command handlers when a selection is made within NatTable?

Thanks,
Rashmy
Re: Enable Eclipse commands based on selections within NatTable [message #899010 is a reply to message #898776] Mon, 30 July 2012 07:27 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1339
Registered: July 2012
Senior Member
Hi,

there are several ways how you can achieve this:

1. It is possible to use the NatTable as an ISelectionProvider. To do this, NatTable brings the RowSelectionProvider. Note that this only works for selection of rows, not cells.
ISelectionProvider selectionProvider = 
	new RowSelectionProvider<T>(
		getSelectionLayer(), 
		getBodyDataProvider(), 
		false);
getSite().setSelectionProvider(selectionProvider);


2. You can hook in your own selection behaviour by implementing ILayerListener and add it to the SelectionLayer. In handleLayerEvent(ILayerEvent) you can check for the selection and activate/deactivate your handler programmatically like described here http://wiki.eclipse.org/Platform_Command_Framework#Handlers

There are examples for creating an ISelectionProvider and ILayerListener in the NatTable examples selection section.

The documentation on selection in NatTable needs to be created. Hopefully we are able to add it soon.

Hope that helps.

Greez,
Dirk
Previous Topic:Tutorials and Examples
Next Topic:Custom Editors
Goto Forum:
  


Current Time: Sun Oct 26 00:19:24 GMT 2014

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

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