Class AbstractListElementHandler

  • All Implemented Interfaces:
    org.eclipse.core.commands.IHandler, org.eclipse.core.commands.IHandler2
    Direct Known Subclasses:
    AbstractMoveElementHandler, OpenEditorHandler, OpenWizardHandler, SortListHandler

    public abstract class AbstractListElementHandler
    extends org.eclipse.core.commands.AbstractHandler
    Abstract handler that works with single element or a collection of metadata objects in a list: Catalogs, Documents, Attributes, Commands, etc.

    Contains support methods to get selected element or a collection of elements, get parent container and containing list.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.eclipse.emf.ecore.EStructuralFeature findReference​(org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EObject child)
      Find a reference from the provided parent model object to the provided child.
      protected org.eclipse.emf.ecore.EStructuralFeature getContainingFeature​(org.eclipse.core.commands.ExecutionEvent event)
      Returns containing feature for current selected metadata element.
      protected org.eclipse.emf.ecore.EStructuralFeature getContainingFeature​(org.eclipse.emf.ecore.EObject element)
      Returns containing feature for the provided metadata element.
      protected org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> getContainingList​(org.eclipse.core.commands.ExecutionEvent event)
      Returns current selected metadata element container list of elements: for Catalog returns list of Catalogs, for Document list of Documents, etc.
      protected org.eclipse.emf.ecore.EObject getElementContainer​(org.eclipse.emf.ecore.EObject element)
      Returns the provided element metadata container.
      protected org.eclipse.emf.ecore.EObject getSelectedElement​(org.eclipse.core.commands.ExecutionEvent event)
      Returns current selected metadata element: Catalog, Document, Attribute, Command etc.
      protected org.eclipse.emf.ecore.EObject getSelectedElementContainer​(org.eclipse.core.commands.ExecutionEvent event)
      Returns current selected element metadata container.
      protected List<org.eclipse.emf.ecore.EObject> getSelectedElements​(org.eclipse.core.commands.ExecutionEvent event)
      Returns a collection of selected metadata elements: Catalog, Document, Attribute, Command etc.
      protected ISelection getSelection​(org.eclipse.core.commands.ExecutionEvent event)
      Returns the selection by the given event.
      protected void setLookupChildren​(boolean lookupChildren)
      Sets the given value to the "lookupChildren" flag.
      • Methods inherited from class org.eclipse.core.commands.AbstractHandler

        addHandlerListener, dispose, fireHandlerChanged, hasListeners, isEnabled, isHandled, removeHandlerListener, setBaseEnabled, setEnabled
      • Methods inherited from class org.eclipse.core.commands.common.EventManager

        addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
      • Methods inherited from interface org.eclipse.core.commands.IHandler

        execute
    • Constructor Detail

      • AbstractListElementHandler

        public AbstractListElementHandler()
    • Method Detail

      • getSelectedElement

        protected org.eclipse.emf.ecore.EObject getSelectedElement​(org.eclipse.core.commands.ExecutionEvent event)
        Returns current selected metadata element: Catalog, Document, Attribute, Command etc. Method takes first of selected elements. Can return null.
        Parameters:
        event - the handler execution event, cannot be null
        Returns:
        current selected metadata element or null if cannot get
      • getSelectedElements

        protected List<org.eclipse.emf.ecore.EObject> getSelectedElements​(org.eclipse.core.commands.ExecutionEvent event)
        Returns a collection of selected metadata elements: Catalog, Document, Attribute, Command etc. Can return empty collection.

        If the "lookupChildren" flag is true then it returns a collection of children elements for adapable selected objects otherwise returns EObject adapters.

        Parameters:
        event - the handler execution event, cannot be null
        Returns:
        a collection of selected metadata elements, never null
        See Also:
        IAdaptable.getAdapter(Class)
      • getSelectedElementContainer

        protected org.eclipse.emf.ecore.EObject getSelectedElementContainer​(org.eclipse.core.commands.ExecutionEvent event)
        Returns current selected element metadata container. Can return null.
        Parameters:
        event - the handler execution event, cannot be null
        Returns:
        a selected element container or null if cannot get
      • getElementContainer

        protected org.eclipse.emf.ecore.EObject getElementContainer​(org.eclipse.emf.ecore.EObject element)
        Returns the provided element metadata container. Can return null.
        Parameters:
        element - the element, cannot be null
        Returns:
        a provided element container or null if cannot get
      • getContainingList

        protected org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> getContainingList​(org.eclipse.core.commands.ExecutionEvent event)
        Returns current selected metadata element container list of elements: for Catalog returns list of Catalogs, for Document list of Documents, etc. Can return null.
        Parameters:
        event - the handler execution event, cannot be null
        Returns:
        a container list of elements or null if cannot get
      • getContainingFeature

        protected org.eclipse.emf.ecore.EStructuralFeature getContainingFeature​(org.eclipse.core.commands.ExecutionEvent event)
        Returns containing feature for current selected metadata element. Can return null.
        Parameters:
        event - the handler execution event, cannot be null
        Returns:
        a containing feature or null if cannot get
      • getContainingFeature

        protected org.eclipse.emf.ecore.EStructuralFeature getContainingFeature​(org.eclipse.emf.ecore.EObject element)
        Returns containing feature for the provided metadata element. Can return null.
        Parameters:
        element - the element, cannot be null
        Returns:
        a containing feature or null if cannot get
      • findReference

        protected org.eclipse.emf.ecore.EStructuralFeature findReference​(org.eclipse.emf.ecore.EObject parent,
                                                                         org.eclipse.emf.ecore.EObject child)
        Find a reference from the provided parent model object to the provided child.
        Parameters:
        parent - the parent object, cannot be null
        child - the child object, cannot be null
        Returns:
        a reference from the provided parent to child or null if not found
      • getSelection

        protected ISelection getSelection​(org.eclipse.core.commands.ExecutionEvent event)
        Returns the selection by the given event.
        Parameters:
        event - the handler execution event, cannot be null
        Returns:
        the selection or null if there isn't any
      • setLookupChildren

        protected void setLookupChildren​(boolean lookupChildren)
        Sets the given value to the "lookupChildren" flag.
        Parameters:
        lookupChildren - the new value of the "lookupChildren" flag to set
        See Also:
        getSelectedElements(ExecutionEvent)