Interface ISaveablesSource
- All Known Implementing Classes:
AbstractDecoratedTextEditor
,AbstractTextEditor
,CommonNavigator
,CompareEditor
,ProjectExplorer
,SaveableCompareEditorInput
,StatusTextEditor
,SyncInfoCompareInput
,TextEditor
IMPORTANT: As of 3.2, implementers of ISaveablesSource
must
satisfy the following conditions:
- If ISaveablesSource is implemented by an IWorkbenchPart:
- the part must implement
ISaveablePart
- if any of its Saveable objects are dirty, the part must return
true
fromISaveablePart.isDirty()
- the part must return
true
fromISaveablePart.isSaveOnCloseNeeded()
if it is dirty (the default behaviour implemented byEditorPart
) - the part must not implement
ISaveablePart2
- the part must implement
- If ISaveablesSource is implemented by a non-part (possible as of 3.2.1
and 3.3):
- the Workbench's
ISaveablesLifecycleListener
(obtained from the Workbench by callingworkbench.getService(ISaveablesLifecycleListener.class)
) must be notified of any change to the result ofgetSaveables()
- getActiveSaveables() should be implemented to return an empty array
- the Workbench's
If any of these conditions are not met, it is undefined whether the Workbench will prompt to save dirty Saveables when closing parts or the Workbench.
These conditions may be relaxed in future releases.
- Since:
- 3.2
-
Method Details
-
getSaveables
Saveable[] getSaveables()Returns the saveables presented by the workbench part. If the return value of this method changes during the lifetime of this part (i.e. after initialization and control creation but before disposal) the part must notify an implicit listener usingISaveablesLifecycleListener.handleLifecycleEvent(SaveablesLifecycleEvent)
.Additions of saveables to the list of saveables of this part are announced using an event of type
SaveablesLifecycleEvent.POST_OPEN
. Removals are announced in a two-stage process, first using an event of typeSaveablesLifecycleEvent.PRE_CLOSE
followed by an event of typeSaveablesLifecycleEvent.POST_CLOSE
. Since firing thePRE_CLOSE
event may trigger prompts to save dirty saveables, the cancellation status of the event must be checked by the part after the notification. When removing only non-dirty saveables,POST_CLOSE
notification is sufficient.The listener is obtained from the part site by calling
partSite.getService(ISaveablesLifecycleListener.class)
.The part must not notify from its initialization methods (e.g.
init
orcreatePartControl
), or from its dispose method. Parts that implementIReusableEditor
must notify when their input is changed throughIReusableEditor.setInput(IEditorInput)
.- Returns:
- the saveables presented by the workbench part
- See Also:
-
getActiveSaveables
Saveable[] getActiveSaveables()Returns the saveables currently active in the workbench part.Certain workbench actions, such as Save, target only the active saveables in the active part. For example, the active saveables could be determined based on the current selection in the part.
- Returns:
- the saveables currently active in the workbench part
-