### Eclipse Workspace Patch 1.0 #P org.eclipse.debug.ui Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java,v retrieving revision 1.37 diff -u -r1.37 LaunchHistory.java --- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java 11 May 2007 18:56:49 -0000 1.37 +++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java 9 Jul 2007 18:10:53 -0000 @@ -50,6 +50,12 @@ private Vector fFavorites = new Vector(); /** + * A new saved flag to prevent save participants from serializing unchanged launch histories. + * @since 3.3.1 + */ + private boolean fSaved = true; + + /** * List of instances of this launch history */ private static List fgLaunchHistoryInstances = new ArrayList(); @@ -87,7 +93,7 @@ /** * Returns if the current history contains the specified ILaunchConfiguration - * @param config the config to look for + * @param config the configuration to look for * @return true if the current history contains the specified configuration, false otherwise * @since 3.3 */ @@ -135,6 +141,27 @@ */ private void fireLaunchHistoryChanged() { DebugUIPlugin.getDefault().getLaunchConfigurationManager().fireLaunchHistoryChanged(); + setSaved(false); + } + + /** + * Returns if the launch history requires saving or not + * @return true if the history needs to be saved, false otherwise + * @since 3.3.1 + */ + public boolean needsSaving() { + return !fSaved; + } + + /** + * Allows the dirty flag for this launch history to be set. + * It is the clients of this class that must set the saved flag to true + * if they have persisted the launch history + * @param saved + * @since 3.3.1 + */ + public void setSaved(boolean saved) { + fSaved = saved; } /** @@ -230,6 +257,7 @@ */ public synchronized void setFavorites(ILaunchConfiguration[] favorites) { fFavorites = new Vector(Arrays.asList(favorites)); + setSaved(false); } /** @@ -240,6 +268,7 @@ public synchronized void addFavorite(ILaunchConfiguration configuration) { if (!fFavorites.contains(configuration)) { fFavorites.add(configuration); + setSaved(false); } } @@ -365,6 +394,7 @@ */ protected synchronized void removeFavorite(ILaunchConfiguration configuration) { fFavorites.remove(configuration); + setSaved(false); } /** Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java,v retrieving revision 1.99 diff -u -r1.99 LaunchConfigurationManager.java --- ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java 31 May 2007 01:53:49 -0000 1.99 +++ ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java 9 Jul 2007 18:10:53 -0000 @@ -390,8 +390,8 @@ Element favs = doc.createElement(IConfigurationElementConstants.FAVORITES); groupElement.appendChild(favs); createEntry(doc, favs, history.getFavorites()); + history.setSaved(true); } - return DebugUIPlugin.serializeDocument(doc); } @@ -432,15 +432,21 @@ return; } } - IPath historyPath = getHistoryFilePath(); - String osHistoryPath = historyPath.toOSString(); - String xml = getHistoryAsXML(); - File file = new File(osHistoryPath); - file.createNewFile(); - - FileOutputStream stream = new FileOutputStream(file); - stream.write(xml.getBytes("UTF8")); //$NON-NLS-1$ - stream.close(); + boolean shouldsave = false; + for(Iterator iter = fLaunchHistories.values().iterator(); iter.hasNext();) { + shouldsave |= ((LaunchHistory)iter.next()).needsSaving(); + } + if(shouldsave) { + IPath historyPath = getHistoryFilePath(); + String osHistoryPath = historyPath.toOSString(); + String xml = getHistoryAsXML(); + File file = new File(osHistoryPath); + file.createNewFile(); + + FileOutputStream stream = new FileOutputStream(file); + stream.write(xml.getBytes("UTF8")); //$NON-NLS-1$ + stream.close(); + } } /**