Class SelectionListenerFactory.Predicates

  • Enclosing class:
    SelectionListenerFactory

    public static class SelectionListenerFactory.Predicates
    extends Object
    Static class to hold the predicates for this factory.
    • Field Detail

      • emptySelection

        public static Predicate<SelectionListenerFactory.ISelectionModel> emptySelection
        A predicate that will test true if the selection is not empty.

        Empty selections can be used to clear the UI but often the UI is left as it is. Use with care.

      • selectionPartVisible

        public static Predicate<SelectionListenerFactory.ISelectionModel> selectionPartVisible
        A predicate that tests true when the part that provides the selection is visible.

        When a part becomes visible it will receive the current selection. However, this selection may come from a part that now has become invisible. This may be unwanted because of the missing visual link.

      • alreadyDelivered

        public static Predicate<SelectionListenerFactory.ISelectionModel> alreadyDelivered
        A predicate that tests true if the selection and the part it came from are the same as the selection listener currently has.

        A part will broadcast its selection again when it gets focus. This can cause unneeded reactions on selections that the listener already has.

      • alreadyDeliveredAnyPart

        public static Predicate<SelectionListenerFactory.ISelectionModel> alreadyDeliveredAnyPart
        A predicate that tests true if the selection is the same as the selection we currently have. No matter which part delivered it.

        Multiple parts can broadcast the same selection. This can cause unneeded reactions on selections that the listener already has.

      • selfMute

        public static Predicate<SelectionListenerFactory.ISelectionModel> selfMute
        A predicate that tests true if the selection originates from its own part.

        A selection is also delivered to the part that created it. In most cases this must be ignored.

      • targetPartVisible

        public static Predicate<SelectionListenerFactory.ISelectionModel> targetPartVisible
        A predicate that tests true if the part that receives the selection is visible.

        A selection is also delivered to parts that are not visible to the user (e.g. in a different perspective or obscured by other parts). In most cases this must be ignored.

    • Constructor Detail

      • Predicates

        public Predicates()
    • Method Detail

      • selectionType

        public static Predicate<SelectionListenerFactory.ISelectionModel> selectionType​(Class<? extends ISelection> selectionType)
        Creates a predicate that tests true if the selection is an instance of the passed selection type.

        Use this predicate if the listener may only see specific selections like IStructuredSelection. This will avoid the listener to be visited on text selections.

        Parameters:
        selectionType - A subclass of ISelection which may not be null.
        Returns:
        the Predicate that filters based on the the selection.
      • selectionSize

        public static Predicate<SelectionListenerFactory.ISelectionModel> selectionSize​(int size)
        Creates a predicate that will test true if the selection is an IStructuredSelection and number of elements matches the passed size.

        A listener might not be able to handle multiple selections. It is bad practice to only react on the first element in the list. In this case, use this predicate to tell the selection framework that the listener only wants to be visited if one element is selected.

        A listener might need two or more selected elements (e.g. in a compare). Use this predicate to tell the selection framework that the listener only wants to be visited if there are enough elements in the selection.

        Parameters:
        size - The number of required elements.
        Returns:
        the Predicate that filters based on the selection size.
        See Also:
        minimalSelectionSize(int)
      • minimalSelectionSize

        public static Predicate<SelectionListenerFactory.ISelectionModel> minimalSelectionSize​(int size)
        Creates a predicate that will test true if the selection is an IStructuredSelection and number of elements is at least the passed size.

        A listener might need two or more selected elements (e.g. in a compare). Use this predicate to tell the selection framework that the listener only wants to be visited if there are enough elements in the selection.

        Parameters:
        size - The number of elements at least in the list.
        Returns:
        the Predicate that filters based on the selection size.
      • adaptsTo

        public static Predicate<SelectionListenerFactory.ISelectionModel> adaptsTo​(Class<?> adapterType)
        Creates a predicate that returns true when all the objects contained in an IStructuredSelection are adaptable to the passed adapter type.

        Listeners often want to react only on specific objects. Use this predicate to only receive selections that contain objects the listener can work with.

        Parameters:
        adapterType - The class that all elements of the selection must extend or implement. It may not be null.
        Returns:
        the Predicate that filters the selection.