Package org.eclipse.handly.ui.search

## Class HandlySearchResultUpdater

- java.lang.Object
- - org.eclipse.handly.ui.search.HandlySearchResultUpdater

- All Implemented Interfaces:
    `IElementChangeListener`

      public class HandlySearchResultUpdater
      extends java.lang.Object
      implements IElementChangeListener

  An `IElementChangeListener` that updates the content of the managed `AbstractHandlySearchResult`s on element change events. Note that it is the client responsibility to subscribe and unsubscribe the updater to change notifications in the appropriate Handly-based model(s).

- - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `add​(AbstractHandlySearchResult searchResult)` | Adds a search result to this updater.
    `void` | `elementChanged​(IElementChangeEvent event)` | Notifies this listener that some element changes have happened.
    `protected java.lang.Iterable<AbstractHandlySearchResult>` | `getSearchResults()` | Returns the search results managed by this updater.
    `protected boolean` | `isPotentialRemoval​(IElementDelta delta)` | Returns whether the given element `CHANGED` delta describes a potential removal of the element.
    `void` | `remove​(AbstractHandlySearchResult searchResult)` | Removes a search result from this updater.

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

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

- - ### Constructor Detail

    - #### HandlySearchResultUpdater

          public HandlySearchResultUpdater()

  - ### Method Detail

    - #### add

          public void add​(AbstractHandlySearchResult searchResult)

      Adds a search result to this updater. Has no effect if an identical search result is already registered.
      Parameters:
        `searchResult` - the search result to add (not `null`)

    - #### remove

          public void remove​(AbstractHandlySearchResult searchResult)

      Removes a search result from this updater. Has no effect if an identical search result is not registered.
      Parameters:
        `searchResult` - the search result to remove (not `null`)

    - #### elementChanged

          public void elementChanged​(IElementChangeEvent event)

      Notifies this listener that some element changes have happened. The supplied event gives details.

      Note: This method may be called in any thread. The event object (and the element delta within it) is valid only for the duration of the invocation of this method.

      This implementation updates the managed search results by removing matches for elements that ceased to exist.

      Specified by:
        `elementChanged` in interface `IElementChangeListener`
      Parameters:
        `event` - the change event (never `null`)

    - #### isPotentialRemoval

          protected boolean isPotentialRemoval​(IElementDelta delta)

      Returns whether the given element `CHANGED` delta describes a potential removal of the element.

      The `HandlySearchResultUpdater` implementation of this method returns `true` if the delta has one or more of the following flags set: `F_MOVED_TO`, `F_OPEN`, `F_CONTENT`.

      Parameters:
        `delta` - never `null`
      Returns:
        `true` if the delta describes a potential removal, and `false` otherwise

    - #### getSearchResults

          protected final java.lang.Iterable<AbstractHandlySearchResult> getSearchResults()

      Returns the search results managed by this updater.
      Returns:
        the managed search results (never `null`)