Package org.eclipse.ui.navigator

## Class SaveablesProvider

- java.lang.Object
- - org.eclipse.ui.navigator.SaveablesProvider

All Implemented Interfaces:
  `IDisposable`

    public abstract class SaveablesProvider
    extends Object
    implements IDisposable

Provides `Saveable` objects to the common navigator, and allows to map between elements in the tree and models.

This class is intended to be subclassed by clients.

Instances of subclasses will be returned from content extensions that implement `IAdaptable`.

Since:
  3.2

### Constructor Summary

Constructors
`protected` `SaveablesProvider()` Creates a new saveable model provider.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `dispose()` Disposes of this saveables provider.
`protected void` `doInit()` May be overridden by clients.
`protected void` `fireSaveablesClosed​(Saveable[] models)` Notifies the listener that the given models were closed in this model provider.
`protected boolean` `fireSaveablesClosing​(Saveable[] models, boolean force)` Notifies the listener that the given models are about to be closed in this model provider.
`protected void` `fireSaveablesDirtyChanged​(Saveable[] models)` Notifies the listener that the given models' dirty state has changed.
`protected void` `fireSaveablesOpened​(Saveable[] models)` Notifies the listener that the given models were opened in this model provider.
`abstract Object[]` `getElements​(Saveable saveable)` Returns the elements representing the given saveable.
`abstract Saveable` `getSaveable​(Object element)` Returns the saveable for the given element, or null if the element does not represent a saveable.
`abstract Saveable[]` `getSaveables()` Returns the saveables reachable through this provider.
`void` `init​(ISaveablesLifecycleListener listener)` Initializes this SaveablesProvider with the given listener, and calls the hook method doInit().

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

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

### Constructor Detail

#### SaveablesProvider

    protected SaveablesProvider()

Creates a new saveable model provider. May only be called by subclasses.

### Method Detail

#### init

    public final void init​(ISaveablesLifecycleListener listener)

Initializes this SaveablesProvider with the given listener, and calls the hook method doInit().

Parameters:
  `listener` -

#### doInit

    protected void doInit()

May be overridden by clients. The default implementation does nothing.

#### fireSaveablesOpened

    protected final void fireSaveablesOpened​(Saveable[] models)

Notifies the listener that the given models were opened in this model provider. This method must be called on the UI thread.

Parameters:
  `models` -

#### fireSaveablesClosing

    protected final boolean fireSaveablesClosing​(Saveable[] models,
                                                 boolean force)

Notifies the listener that the given models are about to be closed in this model provider. This method must be called on the UI thread.

Parameters:
  `models` -
  `force` - true if the closing may be canceled by the user
Returns:
  true if the listener vetoed the closing (may be ignored if force is true)

#### fireSaveablesClosed

    protected final void fireSaveablesClosed​(Saveable[] models)

Notifies the listener that the given models were closed in this model provider. This method must be called on the UI thread.

Parameters:
  `models` -

#### fireSaveablesDirtyChanged

    protected final void fireSaveablesDirtyChanged​(Saveable[] models)

Notifies the listener that the given models' dirty state has changed. This method must be called on the UI thread.

Parameters:
  `models` -

#### getSaveables

    public abstract Saveable[] getSaveables()

Returns the saveables reachable through this provider. Changes to the list of saveables or to the saveables' dirty state must be announced using the appropriate fire* methods.

Returns:
  the saveables returned by this saveables provider.

#### getElements

    public abstract Object[] getElements​(Saveable saveable)

Returns the elements representing the given saveable. It is recommended that a saveable be represented by only one element.

Parameters:
  `saveable` -
Returns:
  the elements representing the given saveable (array may be empty)

#### getSaveable

    public abstract Saveable getSaveable​(Object element)

Returns the saveable for the given element, or null if the element does not represent a saveable.

Parameters:
  `element` -
Returns:
  the saveable for the given element, or null

#### dispose

    public void dispose()

Disposes of this saveables provider. Subclasses may extend, but must call the super implementation.

Specified by:
  `dispose` in interface `IDisposable`