Package org.eclipse.ui.internal
Class SaveablesList
java.lang.Object
org.eclipse.ui.internal.SaveablesList
- All Implemented Interfaces:
ISaveablesLifecycleListener
The model manager maintains a list of open saveable models.
- Since:
- 3.2
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given listener to the list of listeners.void
dirtyChanged
(IWorkbenchPart part) FOR TESTS ONLYFOR TESTS ONLYFOR TESTS ONLYSaveable[]
Returns the list of open models managed by this model manager.getPartsForSaveable
(Saveable model) getSaveables
(List<IWorkbenchPart> parts) void
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.void
void
postOpen
(IWorkbenchPart part) preCloseParts
(List<IWorkbenchPart> partsToClose, boolean addNonPartSources, boolean save, IShellProvider shellProvider, IWorkbenchWindow window) preCloseParts
(List<IWorkbenchPart> partsToClose, boolean addNonPartSources, boolean save, IWorkbenchWindow window, Map<Saveable, ISaveHandler.Save> saveOptions) preCloseParts
(List<IWorkbenchPart> partsToClose, boolean save, IShellProvider shellProvider, IWorkbenchWindow window) preCloseParts
(List<IWorkbenchPart> partsToClose, boolean save, IWorkbenchWindow window) boolean
promptForSaving
(List<Saveable> modelsToSave, IShellProvider shellProvider, IRunnableContext runnableContext, boolean canCancel, boolean stillOpenElsewhere) Prompt the user to save the given saveables.void
Removes the given listener from the list of listeners.boolean
saveModels
(List<Saveable> finalModels, IShellProvider shellProvider, IRunnableContext runnableContext) Save the given models.boolean
saveModels
(List<Saveable> finalModels, IShellProvider shellProvider, IRunnableContext runnableContext, boolean blockUntilSaved) Save the given models.Object[]
testGetSourcesForModel
(Saveable model) For testing purposes.
-
Constructor Details
-
SaveablesList
public SaveablesList()
-
-
Method Details
-
getOpenModels
Returns the list of open models managed by this model manager.- Returns:
- a list of models
-
handleLifecycleEvent
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 interfaceISaveablesLifecycleListener
- Parameters:
event
- the event
-
addModelLifecycleListener
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 changedListeners should ignore all other event types, including PRE_CLOSE. There is no guarantee that listeners are notified before models are closed.
-
removeModelLifecycleListener
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
-
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 savedshellProvider
- 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 canceledstillOpenElsewhere
- 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 savedshellProvider
- 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 savedshellProvider
- 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
-
postOpen
-
dirtyChanged
-
testGetSourcesForModel
For testing purposes. Not to be called by clients.- Returns:
- never null
-
getNonPartSources
- Returns:
- a list of ISaveablesSource objects registered with this saveables list which are not workbench parts.
-
getPartsForSaveable
-
getModelRefCounts
FOR TESTS ONLY -
getModelMap
FOR TESTS ONLY -
getEqualKeys
FOR TESTS ONLY
-