ListSelectionService functions as a conduit between the presentation layer and anything that may want to see or change the selection. The presentation layer pushes selection changes made by the user to ListSelectionService and at the same time listens for changes to selection coming from ListSelectionService.
An implementation of this service is provided with Sapphire. This service is not intended to be implemented by adopters.
Example
In this example, an action handler attaches a listener to the ListSelectionService to refresh action handler's enablement state when selection changes.
public class ExampleActionHandler extends SapphireActionHandler
{
@Override
public void init( SapphireAction action, ActionHandlerDef def )
{
super.init( action, def );
final ListSelectionService selectionService = action.getPart().service( ListSelectionService.class );
final Listener selectionListener = new Listener()
{
@Override
public void handle( Event event )
{
refreshEnablementState();
}
};
selectionService.attach( selectionListener );
attach
(
new Listener()
{
@Override
public void handle( Event event )
{
if( event instanceof DisposeEvent )
{
selectionService.detach( selectionListener );
}
}
}
);
}
}