Class AbstractWorkingSetUpdater

java.lang.Object
org.eclipse.handly.ui.workingset.AbstractWorkingSetUpdater
All Implemented Interfaces:
org.eclipse.ui.IWorkingSetUpdater

public abstract class AbstractWorkingSetUpdater extends 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.
  • Constructor Details

    • 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 Details

    • 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 IElements 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 IResources to IElements.
      Parameters:
      workingSet - never null