Package org.eclipse.handly.ui.workingset

## Class AbstractWorkingSetElementAdapter

- java.lang.Object
- - org.eclipse.handly.ui.workingset.AbstractWorkingSetElementAdapter

- All Implemented Interfaces:
    `org.eclipse.ui.IWorkingSetElementAdapter`

      public abstract class AbstractWorkingSetElementAdapter
      extends java.lang.Object
      implements org.eclipse.ui.IWorkingSetElementAdapter

  A partial implementation of `IWorkingSetElementAdapter`.

  Working set element adapters are capable of transforming possible working set content into the most applicable form. Each model may opt to provide an element adapter for its working sets via the `elementAdapterClass` attribute of the `org.eclipse.ui.workingSets` extension point. The workbench will use the element adapter to help manage addition of elements to working sets for the model.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AbstractWorkingSetElementAdapter()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `org.eclipse.core.runtime.IAdaptable[]` | `adaptElements​(org.eclipse.ui.IWorkingSet ws, org.eclipse.core.runtime.IAdaptable[] elements)`
    `protected abstract org.eclipse.core.runtime.IAdaptable` | `adaptFromResource​(org.eclipse.core.resources.IResource resource)` | Attempts to adapt the given resource to the corresponding element of the underlying model.
    `void` | `dispose()` |
    `protected abstract boolean` | `isModelElement​(org.eclipse.core.runtime.IAdaptable element)` | Returns whether the given element is native to the underlying model.
    `protected void` | `postProcess​(java.util.Collection<org.eclipse.core.runtime.IAdaptable> result)` | Post-processes the collection of elements to be returned from the `adaptElements(IWorkingSet, IAdaptable[])` method.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractWorkingSetElementAdapter

          public AbstractWorkingSetElementAdapter()

  - ### Method Detail

    - #### adaptElements

          public org.eclipse.core.runtime.IAdaptable[] adaptElements​(org.eclipse.ui.IWorkingSet ws,
                                                                     org.eclipse.core.runtime.IAdaptable[] elements)

      This implementation iterates through the given elements in order. If an element is `native` to the underlying model, it is added to a result set. Otherwise, if it could be adapted to an `IResource`, the resource is passed to the `adaptFromResource(IResource)` method and the result is then added to the result set. Lastly, this implementation `post-processes` the result set before returning it.

      Specified by:
        `adaptElements` in interface `org.eclipse.ui.IWorkingSetElementAdapter`

    - #### dispose

          public void dispose()

      Specified by:
        `dispose` in interface `org.eclipse.ui.IWorkingSetElementAdapter`

    - #### isModelElement

          protected abstract boolean isModelElement​(org.eclipse.core.runtime.IAdaptable element)

      Returns whether the given element is native to the underlying model.
      Parameters:
        `element` - never `null`
      Returns:
        `true` if the given element is native to the model, and `false` otherwise

    - #### adaptFromResource

          protected abstract org.eclipse.core.runtime.IAdaptable adaptFromResource​(org.eclipse.core.resources.IResource resource)

      Attempts to adapt the given resource to the corresponding element of the underlying model.
      Parameters:
        `resource` - never `null`
      Returns:
        the (possibly adapted) resource

    - #### postProcess

          protected void postProcess​(java.util.Collection<org.eclipse.core.runtime.IAdaptable> result)

      Post-processes the collection of elements to be returned from the `adaptElements(IWorkingSet, IAdaptable[])` method.

      Default implementation does nothing. Subclasses may override.

      Parameters:
        `result` - the collection of elements to post-process (never `null`)