Class SaveablesList

java.lang.Object
org.eclipse.ui.internal.SaveablesList
All Implemented Interfaces:
ISaveablesLifecycleListener

public class SaveablesList extends Object implements ISaveablesLifecycleListener
The model manager maintains a list of open saveable models.
Since:
3.2
See Also:
  • Constructor Details

    • SaveablesList

      public SaveablesList()
  • Method Details

    • getOpenModels

      public Saveable[] getOpenModels()
      Returns the list of open models managed by this model manager.
      Returns:
      a list of models
    • handleLifecycleEvent

      public void handleLifecycleEvent(SaveablesLifecycleEvent event)
      This implementation of handleModelLifecycleEvent must be called by implementers of ISaveablesSource whenever the list of models of the model source changes, or when the dirty state of models changes. The ISaveablesSource instance must be passed as the source of the event object.

      This method may also be called by objects that hold on to models but are not workbench parts. In this case, the event source must be set to an object that is not an instanceof IWorkbenchPart.

      Corresponding open and close events must originate from the same (identical) event source.

      This method must be called on the UI thread.

      Specified by:
      handleLifecycleEvent in interface ISaveablesLifecycleListener
      Parameters:
      event - the event
    • addModelLifecycleListener

      public void addModelLifecycleListener(ISaveablesLifecycleListener listener)
      Adds the given listener to the list of listeners. Has no effect if the same (identical) listener has already been added. The listener will be notified about changes to the models managed by this model manager. Event types include:
      POST_OPEN when models were added to the list of models
      POST_CLOSE when models were removed from the list of models
      DIRTY_CHANGED when the dirty state of models changed

      Listeners should ignore all other event types, including PRE_CLOSE. There is no guarantee that listeners are notified before models are closed.

    • removeModelLifecycleListener

      public void removeModelLifecycleListener(ISaveablesLifecycleListener listener)
      Removes the given listener from the list of listeners. Has no effect if the given listener is not contained in the list.
    • preCloseParts

      public Object preCloseParts(List<IWorkbenchPart> partsToClose, boolean addNonPartSources, boolean save, IWorkbenchWindow window, Map<Saveable,ISaveHandler.Save> saveOptions)
      Returns:
      the post close info to be passed to postClose
    • preCloseParts

      public Object preCloseParts(List<IWorkbenchPart> partsToClose, boolean save, IWorkbenchWindow window)
      Returns:
      the post close info to be passed to postClose
    • preCloseParts

      public Object preCloseParts(List<IWorkbenchPart> partsToClose, boolean save, IShellProvider shellProvider, IWorkbenchWindow window)
    • preCloseParts

      public Object preCloseParts(List<IWorkbenchPart> partsToClose, boolean addNonPartSources, boolean save, IShellProvider shellProvider, IWorkbenchWindow window)
    • getSaveables

      public Map<IWorkbenchPart,List<Saveable>> getSaveables(List<IWorkbenchPart> parts)
    • promptForSaving

      public boolean promptForSaving(List<Saveable> modelsToSave, IShellProvider shellProvider, IRunnableContext runnableContext, boolean canCancel, boolean stillOpenElsewhere)
      Prompt the user to save the given saveables.
      Parameters:
      modelsToSave - the saveables to be saved
      shellProvider - the provider used to obtain a shell in prompting is required. Clients can use a workbench window for this.
      runnableContext - a runnable context that will be used to provide a progress monitor while the save is taking place. Clients can use a workbench window for this.
      canCancel - whether the operation can be canceled
      stillOpenElsewhere - whether the models are referenced by open parts
      Returns:
      true if the user canceled
    • saveModels

      public boolean saveModels(List<Saveable> finalModels, IShellProvider shellProvider, IRunnableContext runnableContext)
      Save the given models.
      Parameters:
      finalModels - the list of models to be saved
      shellProvider - the provider used to obtain a shell in prompting is required. Clients can use a workbench window for this.
      runnableContext - a runnable context that will be used to provide a progress monitor while the save is taking place. Clients can use a workbench window for this.
      Returns:
      true if the operation was canceled
    • saveModels

      public boolean saveModels(List<Saveable> finalModels, IShellProvider shellProvider, IRunnableContext runnableContext, boolean blockUntilSaved)
      Save the given models.
      Parameters:
      finalModels - the list of models to be saved
      shellProvider - the provider used to obtain a shell in prompting is required. Clients can use a workbench window for this.
      runnableContext - a runnable context that will be used to provide a progress monitor while the save is taking place. Clients can use a workbench window for this.
      Returns:
      true if the operation was canceled
    • postClose

      public void postClose(Object postCloseInfoObject)
    • postOpen

      public void postOpen(IWorkbenchPart part)
    • dirtyChanged

      public void dirtyChanged(IWorkbenchPart part)
    • testGetSourcesForModel

      public Object[] testGetSourcesForModel(Saveable model)
      For testing purposes. Not to be called by clients.
      Returns:
      never null
    • getNonPartSources

      public ISaveablesSource[] getNonPartSources()
      Returns:
      a list of ISaveablesSource objects registered with this saveables list which are not workbench parts.
    • getPartsForSaveable

      public IWorkbenchPart[] getPartsForSaveable(Saveable model)
    • getModelRefCounts

      protected Map<Saveable,Integer> getModelRefCounts()
      FOR TESTS ONLY
    • getModelMap

      protected Map<Object,Set<Saveable>> getModelMap()
      FOR TESTS ONLY
    • getEqualKeys

      protected Map<Saveable,List<Saveable>> getEqualKeys()
      FOR TESTS ONLY