Package 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 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
Modifier and TypeClassDescriptionprotected static class
Utility class used to help process element change events. -
Constructor Summary
ConstructorDescriptionCreates a new instance of the working set updater. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(org.eclipse.ui.IWorkingSet workingSet) protected abstract void
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
Returns the content adapter that defines a mapping between elements of a Handly-based model and the working set's content.protected void
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
Removes the given element change listener from the underlying model.
-
Constructor Details
-
AbstractWorkingSetUpdater
public AbstractWorkingSetUpdater()Creates a new instance of the working set updater. This constructorregisters
an element change listener that updates the content of each of thecontained
working sets bybuilding
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 interfaceorg.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 interfaceorg.eclipse.ui.IWorkingSetUpdater
-
remove
public boolean remove(org.eclipse.ui.IWorkingSet workingSet) - Specified by:
remove
in interfaceorg.eclipse.ui.IWorkingSetUpdater
-
contains
public boolean contains(org.eclipse.ui.IWorkingSet workingSet) - Specified by:
contains
in interfaceorg.eclipse.ui.IWorkingSetUpdater
-
addElementChangeListener
Registers the given element change listener with the underlying model.- Parameters:
listener
- nevernull
-
removeElementChangeListener
Removes the given element change listener from the underlying model.- Parameters:
listener
- nevernull
-
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
(nevernull
)
-
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 toprocessResourceDelta(IResourceDelta, WorkingSetDelta)
. Uses thecontent adapter
to convertIElement
s to working set elements.- Parameters:
delta
- an element delta (nevernull
)result
- the working set delta being built (nevernull
)
-
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 (nevernull
)result
- the working set delta being built (nevernull
)
-
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 thecontent adapter
to adapt working set elements that are notIResource
s toIElement
s.- Parameters:
workingSet
- nevernull
-