Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Rennie2007-07-09 20:18:10 +0000
committerMichael Rennie2007-07-09 20:18:10 +0000
commit9924bd744e3a079073f8d8e38b78cc1468e11d7c (patch)
tree3ef7cdaa20e76c68ac0079b633553e13dc06eaf6
parentfd60a3754fdc56625ac85350ecf5caa868c356f3 (diff)
downloadeclipse.platform.debug-9924bd744e3a079073f8d8e38b78cc1468e11d7c.tar.gz
eclipse.platform.debug-9924bd744e3a079073f8d8e38b78cc1468e11d7c.tar.xz
eclipse.platform.debug-9924bd744e3a079073f8d8e38b78cc1468e11d7c.zip
Bug 194598
44% of time closing projects spent in LaunchManager#resourceChanged
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java26
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java32
2 files changed, 47 insertions, 11 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
index 63ece6c4a..e39acd6a0 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java
@@ -390,8 +390,8 @@ public class LaunchConfigurationManager implements ILaunchListener, ISavePartici
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 @@ public class LaunchConfigurationManager implements ILaunchListener, ISavePartici
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();
+ }
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java
index 1dcb74660..e99b04b39 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java
@@ -50,6 +50,12 @@ public class LaunchHistory implements ILaunchListener, ILaunchConfigurationListe
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 @@ public class LaunchHistory implements ILaunchListener, ILaunchConfigurationListe
/**
* Returns if the current history contains the specified <code>ILaunchConfiguration</code>
- * @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 @@ public class LaunchHistory implements ILaunchListener, ILaunchConfigurationListe
*/
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 class LaunchHistory implements ILaunchListener, ILaunchConfigurationListe
*/
public synchronized void setFavorites(ILaunchConfiguration[] favorites) {
fFavorites = new Vector(Arrays.asList(favorites));
+ setSaved(false);
}
/**
@@ -240,6 +268,7 @@ public class LaunchHistory implements ILaunchListener, ILaunchConfigurationListe
public synchronized void addFavorite(ILaunchConfiguration configuration) {
if (!fFavorites.contains(configuration)) {
fFavorites.add(configuration);
+ setSaved(false);
}
}
@@ -365,6 +394,7 @@ public class LaunchHistory implements ILaunchListener, ILaunchConfigurationListe
*/
protected synchronized void removeFavorite(ILaunchConfiguration configuration) {
fFavorites.remove(configuration);
+ setSaved(false);
}
/**

Back to the top