Class SelectionEnabler


  • public final class SelectionEnabler
    extends java.lang.Object
    Determines the enablement status given a selection. This calculation is done based on the definition of the enablesFor attribute, enablement element, and the selection element found in the IConfigurationElement provided.

    This class can be instantiated by clients. It is not intended to be extended.

    Since:
    3.0 Note: The dependency on org.eclipse.jface.text for ITextSelection must be severed It may be possible to do with IActionFilter generic workbench registers IActionFilter for "size" property against IStructuredSelection workbench text registers IActionFilter for "size" property against ITextSelection code here: sel.getAdapter(IActionFilter.class) As an interim solution, use reflection to access selections implementing ITextSelection
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ANY_NUMBER
      Enablement mode value for ANY_NUMBER
      static int MULTIPLE
      Enablement mode value for MULTIPLE
      static int NONE
      Enablement mode value for NONE
      static int NONE_OR_ONE
      Enablement mode value for NONE_OR_ONE
      static int ONE_OR_MORE
      Enablement mode value for ONE_OR_MORE
      static int UNKNOWN
      Enablement mode value for UNKNOWN
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object object)  
      int hashCode()
      Computes the hash code for this object based on the id.
      boolean isEnabledForSelection​(ISelection selection)
      Check if the receiver is enabled for the given selection.
      static boolean verifyNameMatch​(java.lang.String name, java.lang.String filter)
      Verifies that the given name matches the given wildcard filter.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ANY_NUMBER

        public static final int ANY_NUMBER
        Enablement mode value for ANY_NUMBER
        See Also:
        Constant Field Values
      • MULTIPLE

        public static final int MULTIPLE
        Enablement mode value for MULTIPLE
        See Also:
        Constant Field Values
      • NONE_OR_ONE

        public static final int NONE_OR_ONE
        Enablement mode value for NONE_OR_ONE
        See Also:
        Constant Field Values
      • ONE_OR_MORE

        public static final int ONE_OR_MORE
        Enablement mode value for ONE_OR_MORE
        See Also:
        Constant Field Values
      • UNKNOWN

        public static final int UNKNOWN
        Enablement mode value for UNKNOWN
        See Also:
        Constant Field Values
    • Constructor Detail

      • SelectionEnabler

        public SelectionEnabler​(IConfigurationElement configElement)
        Create a new instance of the receiver.
        Parameters:
        configElement - the configuration element to parse
    • Method Detail

      • verifyNameMatch

        public static boolean verifyNameMatch​(java.lang.String name,
                                              java.lang.String filter)
        Verifies that the given name matches the given wildcard filter. Returns true if it does.
        Parameters:
        name - the name to match
        filter - the filter to match to
        Returns:
        true if there is a match
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Computes the hash code for this object based on the id.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hash code for this object.
      • isEnabledForSelection

        public boolean isEnabledForSelection​(ISelection selection)
        Check if the receiver is enabled for the given selection.
        Parameters:
        selection - the selection
        Returns:
        true if the given selection matches the conditions specified in IConfirgurationElement.