Interface ISelectionService

  • All Known Subinterfaces:
    IWorkbenchPage

    public interface ISelectionService
    A selection service tracks the selection within an object.

    A listener that wants to be notified when the selection becomes null must implement the INullSelectionListener interface.

    This service can be acquired from your service locator:

     ISelectionService service = (ISelectionService) getSite().getService(ISelectionService.class);
     
    This service is not available globally, only from the workbench window level down.
    See Also:
    ISelectionListener, INullSelectionListener, IServiceLocator.getService(Class)
    Restriction:
    This interface is not intended to be implemented by clients.
    • Method Detail

      • getSelection

        ISelection getSelection()
        Returns the current selection in the active part. If the selection in the active part is undefined (the active part has no selection provider) the result will be null.
        Returns:
        the current selection, or null if undefined
      • getSelection

        ISelection getSelection​(String partId)
        Returns the current selection in the part with the given id. If the part is not open, or if the selection in the active part is undefined (the active part has no selection provider) the result will be null.
        Parameters:
        partId - the id of the part
        Returns:
        the current selection, or null if undefined
        Since:
        2.0
      • removeSelectionListener

        void removeSelectionListener​(ISelectionListener listener)
        Removes the given selection listener. Has no effect if an identical listener is not registered.
        Parameters:
        listener - a selection listener
      • removeSelectionListener

        void removeSelectionListener​(String partId,
                                     ISelectionListener listener)
        Removes the given part-specific selection listener. Has no effect if an identical listener is not registered for the given part id.
        Parameters:
        partId - the id of the part to track
        listener - a selection listener
        Since:
        2.0
      • removePostSelectionListener

        void removePostSelectionListener​(ISelectionListener listener)
        Removes the given post selection listener. Has no effect if an identical listener is not registered.
        Parameters:
        listener - a selection listener
      • removePostSelectionListener

        void removePostSelectionListener​(String partId,
                                         ISelectionListener listener)
        Removes the given part-specific post selection listener. Has no effect if an identical listener is not registered for the given part id.
        Parameters:
        partId - the id of the part to track
        listener - a selection listener
        Since:
        2.0