### Eclipse Workspace Patch 1.0 #P org.eclipse.core.resources Index: src/org/eclipse/core/internal/resources/SaveManager.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java,v retrieving revision 1.101 diff -u -r1.101 SaveManager.java --- src/org/eclipse/core/internal/resources/SaveManager.java 5 Oct 2009 21:40:29 -0000 1.101 +++ src/org/eclipse/core/internal/resources/SaveManager.java 30 Oct 2009 10:58:14 -0000 @@ -100,17 +100,16 @@ saveParticipants = Collections.synchronizedMap(new HashMap(10)); } - public ISavedState addParticipant(Plugin plugin, ISaveParticipant participant) throws CoreException { + public ISavedState addParticipant(String pluginId, ISaveParticipant participant) throws CoreException { // If the plugin was already registered as a save participant we return null - if (saveParticipants.put(plugin, participant) != null) + if (saveParticipants.put(pluginId, participant) != null) return null; - String id = plugin.getBundle().getSymbolicName(); - SavedState state = (SavedState) savedStates.get(id); + SavedState state = (SavedState) savedStates.get(pluginId); if (state != null) { - if (isDeltaCleared(id)) { + if (isDeltaCleared(pluginId)) { // this plugin was marked not to receive deltas state.forgetTrees(); - removeClearDeltaMarks(id); + removeClearDeltaMarks(pluginId); } else { try { // thread safety: (we need to guarantee that the tree is immutable when computing deltas) @@ -125,8 +124,8 @@ } } // if the plug-in has a previous save number, we return a state, otherwise we return null - if (getSaveNumber(id) > 0) - return new SavedState(workspace, id, null, null); + if (getSaveNumber(pluginId) > 0) + return new SavedState(workspace, pluginId, null, null); return null; } @@ -536,8 +535,8 @@ } } - public void removeParticipant(Plugin plugin) { - saveParticipants.remove(plugin); + public void removeParticipant(String pluginId) { + saveParticipants.remove(pluginId); } protected void removeUnusedSafeTables() { Index: src/org/eclipse/core/internal/resources/Workspace.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java,v retrieving revision 1.222 diff -u -r1.222 Workspace.java --- src/org/eclipse/core/internal/resources/Workspace.java 5 Oct 2009 21:40:29 -0000 1.222 +++ src/org/eclipse/core/internal/resources/Workspace.java 30 Oct 2009 10:58:15 -0000 @@ -276,7 +276,16 @@ public ISavedState addSaveParticipant(Plugin plugin, ISaveParticipant participant) throws CoreException { Assert.isNotNull(plugin, "Plugin must not be null"); //$NON-NLS-1$ Assert.isNotNull(participant, "Participant must not be null"); //$NON-NLS-1$ - return saveManager.addParticipant(plugin, participant); + return saveManager.addParticipant(plugin.getBundle().getSymbolicName(), participant); + } + + /* (non-Javadoc) + * @see IWorkspace#addSaveParticipant(String, ISaveParticipant) + */ + public ISavedState addSaveParticipant(String pluginId, ISaveParticipant participant) throws CoreException { + Assert.isNotNull(pluginId, "Plugin id must not be null"); //$NON-NLS-1$ + Assert.isNotNull(participant, "Participant must not be null"); //$NON-NLS-1$ + return saveManager.addParticipant(pluginId, participant); } public void beginOperation(boolean createNewTree) throws CoreException { @@ -1812,7 +1821,15 @@ */ public void removeSaveParticipant(Plugin plugin) { Assert.isNotNull(plugin, "Plugin must not be null"); //$NON-NLS-1$ - saveManager.removeParticipant(plugin); + saveManager.removeParticipant(plugin.getBundle().getSymbolicName()); + } + + /* (non-Javadoc) + * @see IWorkspace#removeSaveParticipant(String) + */ + public void removeSaveParticipant(String pluginId) { + Assert.isNotNull(pluginId, "Plugin id must not be null"); //$NON-NLS-1$ + saveManager.removeParticipant(pluginId); } /* (non-Javadoc) Index: src/org/eclipse/core/resources/IWorkspace.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/resources/IWorkspace.java,v retrieving revision 1.85 diff -u -r1.85 IWorkspace.java --- src/org/eclipse/core/resources/IWorkspace.java 5 Oct 2009 21:40:29 -0000 1.85 +++ src/org/eclipse/core/resources/IWorkspace.java 30 Oct 2009 10:58:15 -0000 @@ -168,8 +168,32 @@ * * @see ISaveParticipant * @see #removeSaveParticipant(Plugin) + * @deprecated Use {@link #addSaveParticipant(String, ISaveParticipant)} instead */ public ISavedState addSaveParticipant(Plugin plugin, ISaveParticipant participant) throws CoreException; + + /** + * Registers the given bundle's workspace save participant, and returns an + * object describing the workspace state at the time of the last save in + * which the bundle participated. + *

+ * Once registered, the workspace save participant will actively participate + * in the saving of this workspace. + *

+ * + * @param pluginId the unique identifier of the plug-in + * @param participant the participant + * @return the last saved state in which the plug-in participated, or + * null if the plug-in has not participated before + * @exception CoreException if the method fails to add the participant. + * Reasons include: + * + * @see ISaveParticipant + * @see #removeSaveParticipant(String) + */ + public ISavedState addSaveParticipant(String pluginId, ISaveParticipant participant) throws CoreException; /** * Builds all projects in this workspace. Projects are built in the order @@ -935,8 +959,23 @@ * @param plugin the plug-in * @see ISaveParticipant * @see #addSaveParticipant(Plugin, ISaveParticipant) + * @deprecated Use {@link #removeSaveParticipant(String)} instead */ public void removeSaveParticipant(Plugin plugin); + + /** + * Removes the workspace save participant for the given plug-in from this + * workspace. If no such participant is registered, no action is taken. + *

+ * Once removed, the workspace save participant no longer actively + * participates in any future saves of this workspace. + *

+ * + * @param pluginId the unique identifier of the plug-in + * @see ISaveParticipant + * @see #addSaveParticipant(String, ISaveParticipant) + */ + public void removeSaveParticipant(String pluginId); /** * Runs the given action as an atomic workspace operation.