# ListSelectionService

ListSelectionService is a conduit between the presentation layer and anything that needs to observe or change the selection in a list property editor. 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.

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( final SapphireAction action, final ActionHandlerDef def )
        {
            super.init( action, def );

            final ListSelectionService listSelectionService = action.getPart().service( ListSelectionService.class );

            final Listener listSelectionListener = new Listener()
            {
                @Override

                public void handle( final Event event )
                {
                    refreshEnablementState();
                }
            };

            listSelectionService.attach( listSelectionListener );

            attach
            (
                new FilteredListener<DisposeEvent>()
                {
                    @Override

                    protected void handleTypedEvent( final DisposeEvent event )
                    {
                        listSelectionService.detach( listSelectionListener );
                    }
                }
            );
        }
    }

Copyright (c) 2016 Oracle and Liferay
Content made available under the terms of Eclipse Public License.