Interface ISaveContext
-
public interface ISaveContextA context for workspacesaveoperations.Note that
IWorkspace.saveuses a different save context for each registered participant, allowing each to declare whether they have actively participated and decide whether to receive a resource delta on reactivation.- See Also:
IWorkspace.save(boolean, org.eclipse.core.runtime.IProgressMonitor)- Restriction:
- This interface is not intended to be implemented by clients.
- Restriction:
- This interface is not intended to be extended by clients.
-
-
Field Summary
Fields Modifier and Type Field Description static intFULL_SAVEType constant which identifies a full save.static intPROJECT_SAVEType constant which identifies a project save.static intSNAPSHOTType constant which identifies a snapshot.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IPath[]getFiles()Returns current files mapped with theISaveContext.mapfacility or an empty array if there are no mapped files.intgetKind()Returns the type of this save.intgetPreviousSaveNumber()Returns the number for the previous save in which the plug-in actively participated, or0if the plug-in has never actively participated in a save before.IProjectgetProject()If the current save is a project save, this method returns the project being saved.intgetSaveNumber()Returns the number for this save.IPathlookup(IPath file)Returns the current location for the given file ornullif none.voidmap(IPath file, IPath location)Maps the given plug-in file to its real location.voidneedDelta()Indicates that the saved workspace tree should be remembered so that a delta will be available in a subsequent session when the plug-in re-registers to participate in saves.voidneedSaveNumber()Indicates that this participant has actively participated in this save.
-
-
-
Field Detail
-
FULL_SAVE
static final int FULL_SAVE
Type constant which identifies a full save.- See Also:
getKind(), Constant Field Values
-
SNAPSHOT
static final int SNAPSHOT
Type constant which identifies a snapshot.- See Also:
getKind(), Constant Field Values
-
PROJECT_SAVE
static final int PROJECT_SAVE
Type constant which identifies a project save.- See Also:
getKind(), Constant Field Values
-
-
Method Detail
-
getFiles
IPath[] getFiles()
Returns current files mapped with theISaveContext.mapfacility or an empty array if there are no mapped files.- Returns:
- the files currently mapped by the participant
- See Also:
map(IPath, IPath)
-
getKind
int getKind()
Returns the type of this save. The types can be:-
ISaveContext.FULL_SAVE -
ISaveContext.SNAPSHOT -
ISaveContext.PROJECT_SAVE
- Returns:
- the type of the current save
-
-
getPreviousSaveNumber
int getPreviousSaveNumber()
Returns the number for the previous save in which the plug-in actively participated, or0if the plug-in has never actively participated in a save before.In the event of an unsuccessful save, this is the value to
rollbackto.- Returns:
- the previous save number if positive, or
0if never saved before - See Also:
ISaveParticipant.rollback(ISaveContext)
-
getProject
IProject getProject()
If the current save is a project save, this method returns the project being saved.- Returns:
- the project being saved or
nullif this is not project save - See Also:
getKind()
-
getSaveNumber
int getSaveNumber()
Returns the number for this save. This number is guaranteed to be1more than the previous save number.This is the value to use when, for example, creating files in which a participant will save its data.
- Returns:
- the save number
- See Also:
ISaveParticipant.saving(ISaveContext)
-
lookup
IPath lookup(IPath file)
Returns the current location for the given file ornullif none.- Returns:
- the location of a given file or
null - See Also:
map(IPath, IPath),ISavedState.lookup(IPath)
-
map
void map(IPath file, IPath location)
Maps the given plug-in file to its real location. This method is intended to be used withISaveContext.getSaveNumber()to map plug-in configuration file names to real locations.For example, assume a plug-in has a configuration file named "config.properties". The map facility can be used to map that logical name onto a real name which is specific to a particular save (e.g., 10.config.properties, where 10 is the current save number). The paths specified here should always be relative to the plug-in state location for the plug-in saving the state.
Each save participant must manage the deletion of its old state files. Old state files can be discovered using
getPreviousSaveNumberor by usinggetFilesto discover the current files and comparing that to the list of files on disk.- Parameters:
file- the logical name of the participant's data filelocation- the real (i.e., filesystem) name by which the file should be known for this save, ornullto remove the entry- See Also:
lookup(IPath),getSaveNumber(),needSaveNumber(),ISavedState.lookup(IPath)
-
needDelta
void needDelta()
Indicates that the saved workspace tree should be remembered so that a delta will be available in a subsequent session when the plug-in re-registers to participate in saves. If this method is not called, no resource delta will be made available. This facility is not available for marker deltas. Plug-ins must assume that all markers may have changed when they are activated.Note that this is orthogonal to
needSaveNumber. That is, one can ask for a delta regardless of whether or not one is an active participant.Note that deltas are not guaranteed to be saved even if saving is requested. Deltas cannot be supplied where the previous state is too old or has become invalid.
This method is only valid for full saves. It is ignored during snapshots or project saves.
-
needSaveNumber
void needSaveNumber()
Indicates that this participant has actively participated in this save. If the save is successful, the current save number will be remembered; this save number will be the previous save number for subsequent saves until the participant again actively participates.If this method is not called, the plug-in is not deemed to be an active participant in this save.
Note that this is orthogonal to
needDelta. That is, one can be an active participant whether or not one asks for a delta.
-
-