org.eclipse.handly.ui.workingset

## Class AbstractWorkingSetUpdater

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

- All Implemented Interfaces:
    org.eclipse.ui.IWorkingSetUpdater

      public abstract class AbstractWorkingSetUpdater
      extends java.lang.Object
      implements org.eclipse.ui.IWorkingSetUpdater

  An almost complete implementation of `IWorkingSetUpdater` for Handly-based models. Updates element working sets on element change events. Subclasses need to implement a couple of abstract methods for subscription to change notifications in the underlying model.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `AbstractWorkingSetUpdater.WorkingSetDelta` Utility class used to help process element change events.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractWorkingSetUpdater()` Creates a new instance of the working set updater.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(org.eclipse.ui.IWorkingSet workingSet)`
    `protected abstract void` | `addElementChangeListener(IElementChangeListener listener)` Registers the given element change listener with the underlying model.
    `protected void` | `checkElementExistence(org.eclipse.ui.IWorkingSet workingSet)` Removes elements that do not exist anymore from the given working set, except for elements under closed projects.
    `boolean` | `contains(org.eclipse.ui.IWorkingSet workingSet)`
    `void` | `dispose()`
    `protected IContentAdapter` | `getContentAdapter()` Returns the content adapter that defines a mapping between elements of a Handly-based model and the working set's content.
    `protected void` | `processElementDelta(IElementDelta delta, AbstractWorkingSetUpdater.WorkingSetDelta result)` Builds a working set delta by recursively processing the given element delta.
    `protected void` | `processResourceDelta(org.eclipse.core.resources.IResourceDelta delta, AbstractWorkingSetUpdater.WorkingSetDelta result)` Builds a working set delta by recursively processing the given resource delta.
    `boolean` | `remove(org.eclipse.ui.IWorkingSet workingSet)`
    `protected abstract void` | `removeElementChangeListener(IElementChangeListener listener)` Removes the given element change listener from the underlying model.

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

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

- - ### Constructor Detail

    - #### AbstractWorkingSetUpdater

          public AbstractWorkingSetUpdater()

      Creates a new instance of the working set updater. This constructor `registers` an element change listener that updates the content of each of the `contained` working sets by `building` and applying a working set delta.

      It is the client responsibility to `dispose` the created instance after it is no longer needed.

  - ### Method Detail

    - #### dispose

          public void dispose()

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

    - #### add

          public void add(org.eclipse.ui.IWorkingSet workingSet)

      This implementation invokes `checkElementExistence(IWorkingSet)` before adding the working set to this updater.

      Specified by:
        `add` in interface `org.eclipse.ui.IWorkingSetUpdater`

    - #### remove

          public boolean remove(org.eclipse.ui.IWorkingSet workingSet)

      Specified by:
        `remove` in interface `org.eclipse.ui.IWorkingSetUpdater`

    - #### contains

          public boolean contains(org.eclipse.ui.IWorkingSet workingSet)

      Specified by:
        `contains` in interface `org.eclipse.ui.IWorkingSetUpdater`

    - #### addElementChangeListener

          protected abstract void addElementChangeListener(IElementChangeListener listener)

      Registers the given element change listener with the underlying model.
      Parameters:
        `listener` - never `null`

    - #### removeElementChangeListener

          protected abstract void removeElementChangeListener(IElementChangeListener listener)

      Removes the given element change listener from the underlying model.
      Parameters:
        `listener` - never `null`

    - #### getContentAdapter

          protected IContentAdapter getContentAdapter()

      Returns the content adapter that defines a mapping between elements of a Handly-based model and the working set's content.

      Default implementation returns a `NullContentAdapter`. Subclasses may override.

      Returns:
        an `IContentAdapter` (never `null`)

    - #### processElementDelta

          protected void processElementDelta(IElementDelta delta,
                                             AbstractWorkingSetUpdater.WorkingSetDelta result)

      Builds a working set delta by recursively processing the given element delta. Delegates the processing of resource deltas contained in the element delta to `processResourceDelta(IResourceDelta, WorkingSetDelta)`. Uses the `content adapter` to convert `IElement`s to working set elements.
      Parameters:
        `delta` - an element delta (never `null`)
        `result` - the working set delta being built (never `null`)

    - #### processResourceDelta

          protected void processResourceDelta(org.eclipse.core.resources.IResourceDelta delta,
                                              AbstractWorkingSetUpdater.WorkingSetDelta result)

      Builds a working set delta by recursively processing the given resource delta.
      Parameters:
        `delta` - a resource delta (never `null`)
        `result` - the working set delta being built (never `null`)

    - #### checkElementExistence

          protected void checkElementExistence(org.eclipse.ui.IWorkingSet workingSet)

      Removes elements that do not exist anymore from the given working set, except for elements under closed projects. Uses the `content adapter` to adapt working set elements that are not `IResource`s to `IElement`s.
      Parameters:
        `workingSet` - never `null`

Copyright (c) 2014, 2020 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0