[309781] Deadlock during debugging
diff --git a/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html b/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html
index 74e5e1f..5813422 100644
--- a/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html
+++ b/features/org.eclipse.wst.server_core.feature.patch/buildnotes_org.eclipse.wst.server_core.feature.patch.html
@@ -24,5 +24,6 @@
 <p>Bug <a href='https://bugs.eclipse.org/322261'>322261</a>. WTP needs an API on ServerPublishInfo to rebuild the cache for a specific module</p>
 <p>Bug <a href='https://bugs.eclipse.org/322968'>322968</a>. The ability to update server's launch is required</p>
 <p>Bug <a href='https://bugs.eclipse.org/323658'>323658</a>. NPE- modules variable not initialized when API called during automated scenario</p>
+<p>Bug <a href='https://bugs.eclipse.org/309781'>309781</a>. Deadlock during debugging</p>
 
 </body></html>
\ No newline at end of file
diff --git a/features/org.eclipse.wst.server_core.feature.patch/feature.properties b/features/org.eclipse.wst.server_core.feature.patch/feature.properties
index b98b5d0..a7e8ffa 100644
--- a/features/org.eclipse.wst.server_core.feature.patch/feature.properties
+++ b/features/org.eclipse.wst.server_core.feature.patch/feature.properties
@@ -36,6 +36,7 @@
 Bug https://bugs.eclipse.org/322261 WTP needs an API on ServerPublishInfo to rebuild the cache for a specific module\n\
 Bug https://bugs.eclipse.org/322968 The ability to update server's launch is required\n\
 Bug https://bugs.eclipse.org/323658 NPE- modules variable not initialized when API called during automated scenario\n\
+Bug https://bugs.eclipse.org/309781 Deadlock during debugging\n\
 \n\
 
 # "copyright" property - text of the "Feature Update Copyright"
diff --git a/features/org.eclipse.wst.server_ui.feature.patch/buildnotes_org.eclipse.wst.server_ui.feature.patch.html b/features/org.eclipse.wst.server_ui.feature.patch/buildnotes_org.eclipse.wst.server_ui.feature.patch.html
index f45cdc7..82f71f2 100644
--- a/features/org.eclipse.wst.server_ui.feature.patch/buildnotes_org.eclipse.wst.server_ui.feature.patch.html
+++ b/features/org.eclipse.wst.server_ui.feature.patch/buildnotes_org.eclipse.wst.server_ui.feature.patch.html
@@ -16,5 +16,6 @@
 <ul><li>org.eclipse.wst.server.ui</li></ul>
 <p>Bug <a href='https://bugs.eclipse.org/286960'>286960</a>. Cannot delete a module using the delete key button on servers view.</p>
 <p>Bug <a href='https://bugs.eclipse.org/291960'>291960</a>. XMLViewer makes (apparently) invalid assumptions about TransformerFactory</p>
+<p>Bug <a href='https://bugs.eclipse.org/309781'>309781</a>. Deadlock during debugging</p>
 
 </body></html>
\ No newline at end of file
diff --git a/features/org.eclipse.wst.server_ui.feature.patch/feature.properties b/features/org.eclipse.wst.server_ui.feature.patch/feature.properties
index 48cbb0e..e043e9d 100644
--- a/features/org.eclipse.wst.server_ui.feature.patch/feature.properties
+++ b/features/org.eclipse.wst.server_ui.feature.patch/feature.properties
@@ -29,6 +29,7 @@
 \n\
 Bug https://bugs.eclipse.org/286960 Cannot delete a module using the delete key button on servers view.\n\
 Bug https://bugs.eclipse.org/291960 XMLViewer makes (apparently) invalid assumptions about TransformerFactory\n\
+Bug https://bugs.eclipse.org/309781 Deadlock during debugging\n\
 \n\
 
 # "copyright" property - text of the "Feature Update Copyright"
diff --git a/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
index f3b58e6..702a393 100644
--- a/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.server.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.wst.server.core; singleton:=true
-Bundle-Version: 1.1.12.qualifier
+Bundle-Version: 1.1.13.qualifier
 Bundle-Activator: org.eclipse.wst.server.core.internal.ServerPlugin
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.wst.server.core/plugin.properties b/plugins/org.eclipse.wst.server.core/plugin.properties
index 516680b..7dda41d 100644
--- a/plugins/org.eclipse.wst.server.core/plugin.properties
+++ b/plugins/org.eclipse.wst.server.core/plugin.properties
@@ -27,6 +27,7 @@
 extensionPointServerMonitors=Server Monitors
 extensionPointInstallableServers=Installable Servers
 extensionPointInstallableRuntimes=Installable Runtimes
+extensionPointSaveEditorPrompter=Save Editor Prompter
 
 extensionPointRuntimeFacetComponentProviders=Runtime Facet Component Providers
 
diff --git a/plugins/org.eclipse.wst.server.core/plugin.xml b/plugins/org.eclipse.wst.server.core/plugin.xml
index 3e69244..10a1fcf 100644
--- a/plugins/org.eclipse.wst.server.core/plugin.xml
+++ b/plugins/org.eclipse.wst.server.core/plugin.xml
@@ -19,6 +19,7 @@
   <extension-point id="installableServers" name="%extensionPointInstallableServers" schema="schema/installableServers.exsd"/>
   <extension-point id="installableRuntimes" name="%extensionPointInstallableRuntimes" schema="schema/installableRuntimes.exsd"/>
   <extension-point id="runtimeFacetComponentProviders" name="%extensionPointRuntimeFacetComponentProviders" schema="schema/runtimeFacetComponentProviders.exsd"/>
+  <extension-point id="saveEditorPrompter" name="%extensionPointSaveEditorPrompter" schema="schema/saveEditorPrompter.exsd"/>
 
   <extension point="org.eclipse.wst.server.core.moduleTypes">
     <moduleType
@@ -34,4 +35,4 @@
       id="org.eclipse.wst.server.core.default"
       class="org.eclipse.wst.server.core.internal.facets.RuntimeBridge"/>
   </extension>
-</plugin>
\ No newline at end of file
+</plugin>
diff --git a/plugins/org.eclipse.wst.server.core/schema/saveEditorPrompter.exsd b/plugins/org.eclipse.wst.server.core/schema/saveEditorPrompter.exsd
new file mode 100644
index 0000000..aeafbb7
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.core/schema/saveEditorPrompter.exsd
@@ -0,0 +1,121 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.wst.server.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.wst.server.core" id="saveEditorPrompter" name="%saveEditorPrompter"/>
+      </appInfo>
+      <documentation>
+         This is an internal extension point that should only be adopted by org.eclipse.wst.server.core. It is used to transfer the control to the UI and save all the editors are open before continuing
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="saveEditorPrompter"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="saveEditorPrompter">
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.wst.server.core.internal.SaveEditorPrompter:"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiinfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2010 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made 
+available under the terms of the Eclipse Public License v1.0 which accompanies 
+this distribution, and is available at 
+&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/SaveEditorPrompter.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/SaveEditorPrompter.java
new file mode 100644
index 0000000..8e45842
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/SaveEditorPrompter.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.wst.server.core.internal;
+
+/**
+ * <p>
+ * SaveEditorPrompter is the abstract implementation of the .saveEditorPrompter extension 
+ * point. This class is used for prompting to the user to save all the editors. The class 
+ * transfer the control from the non-ui code to the UI code via an the extension point
+ * </p>
+ * <b>This class is not intended to be extended adopters.</b> 
+ * 
+ */
+public class SaveEditorPrompter {
+	
+	/**
+	 * Move the control to the UI and save all the editors according to <code>org.eclipse.debug.internal.ui.IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH</code>  
+	 */
+	public void saveAllEditors(){
+		// nothing to do, should be implemented		
+	}
+	public void setDebugNeverSave(){
+		// nothing to do, should be implemented		
+	}
+	public void setDebugOriginalValue(){
+		// nothing to do, should be implemented		
+	}
+}
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
index cb7a7ab..3fcd580 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
@@ -1784,6 +1784,10 @@
 			return;
 		}
 		
+		if (ServerPlugin.isRunningGUIMode()){
+			ServerPlugin.getSaveEditorHelper().saveAllEditors();
+		}
+		
 		StartJob startJob = new StartJob(mode2);
 		startJob.schedule();
 		
@@ -1820,7 +1824,11 @@
 			else
 				pub = StartJob.PUBLISH_BEFORE;
 		}
-
+		
+		if (ServerPlugin.isRunningGUIMode()){
+			ServerPlugin.getSaveEditorHelper().saveAllEditors();
+		}
+		
 		StartJob startJob = new StartJob(mode2);
 		if (opListener != null && pub != StartJob.PUBLISH_AFTER) {
 			startJob.addJobChangeListener(new JobChangeAdapter() {
@@ -1849,6 +1857,10 @@
 			return;
 		}
 		
+		if (ServerPlugin.isRunningGUIMode()){
+			ServerPlugin.getSaveEditorHelper().saveAllEditors();
+		}
+		
 		StartJob startJob = new StartJob(mode2);
 		startJob.schedule();
 		
@@ -2894,15 +2906,23 @@
 
 	protected void startImpl2(String mode2, IProgressMonitor monitor) throws CoreException {
 		Trace.trace(Trace.FINEST, "Starting server: " + Server.this.toString() + ", launchMode: " + mode2);
-		
+		SaveEditorPrompter editorHelper = (ServerPlugin.isRunningGUIMode()) ? ServerPlugin.getSaveEditorHelper() : null;
 		// make sure that the delegate is loaded and the server state is correct
 		loadAdapter(ServerBehaviourDelegate.class, monitor);
 		
 		try {
 			ILaunchConfiguration launchConfig = getLaunchConfiguration(true, monitor);
-			//if (launchConfig == null)
-			//	throw new CoreException();
+			
+			if (editorHelper != null){
+				editorHelper.setDebugNeverSave();
+			}
+			
 			launch = launchConfig.launch(mode2, monitor); // , true); - causes workspace lock
+			
+			if (editorHelper != null){
+				editorHelper.setDebugOriginalValue();
+			}
+			
 			Trace.trace(Trace.FINEST, "Launch: " + launch);
 		} catch (CoreException e) {
 			Trace.trace(Trace.SEVERE, "Error starting server " + Server.this.toString(), e);
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPlugin.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPlugin.java
index bac80b2..7057b14 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPlugin.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPlugin.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2010 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -26,6 +26,7 @@
 import org.eclipse.wst.server.core.IServerAttributes;
 import org.eclipse.wst.server.core.IServerWorkingCopy;
 import org.eclipse.wst.server.core.ServerCore;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
@@ -75,6 +76,12 @@
 	//	cached copy of all installable runtimes
 	private static List<IInstallableRuntime> installableRuntimes;
 
+	// cached copy of SaveEditorPrompter
+	private static SaveEditorPrompter saveEditorPrompter;
+	
+	// cached copy of isRunningInGUICache
+	public static boolean isRunningInGUICache = false;
+
 	// registry listener
 	private static IRegistryChangeListener registryListener;
 	
@@ -1237,4 +1244,52 @@
 			return Platform.getProduct().getProperty(key);
 		return value;
 	}
+	
+	public static boolean isRunningGUIMode(){
+		// check only when the the plugin is not Bundle.ACTIVE
+		if (isRunningInGUICache == true){
+			return isRunningInGUICache;
+		}
+
+		Bundle swtEclipseUIbndl = Platform.getBundle("org.eclipse.ui");  //running in GUI mode if it is active.
+		if(swtEclipseUIbndl != null){
+			isRunningInGUICache= (swtEclipseUIbndl.getState() == Bundle.ACTIVE);
+			return isRunningInGUICache; 
+		}			
+		return false;
+	}	
+
+
+	/**
+	 * Transfer the control to the UI and prompts to save all the editors
+	 */
+	public static SaveEditorPrompter getSaveEditorHelper() {
+		loadSaveEditorExtension();
+		return saveEditorPrompter;
+	}
+
+	private static void loadSaveEditorExtension() {
+		if (saveEditorPrompter != null)
+			return;
+		Trace.trace(Trace.EXTENSION_POINT, "->- Loading .saveEditorPrompter extension point ->-");
+		
+		IExtensionRegistry registry = Platform.getExtensionRegistry();
+		IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerPlugin.PLUGIN_ID, "saveEditorPrompter");
+		
+		int size = cf.length;
+		try{
+			saveEditorPrompter = (SaveEditorPrompter)cf[0].createExecutableExtension("class");
+			Trace.trace(Trace.EXTENSION_POINT, "  Loaded saveEditorPrompter: " + cf[0].getAttribute("id"));
+		} catch (CoreException ce){
+			Trace.trace(Trace.SEVERE, "  Could not load saveEditorPrompter: " + cf[0].getAttribute("id"), ce);			
+		}
+		if (size < 1) {
+			Trace.trace(Trace.WARNING, "  More than one .saveEditorPrompter found, only one loaded =>"+ cf[0].getAttribute("id"));
+		}
+		
+		Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .saveEditorPrompter extension point -<-");
+		
+	}
+	
+	
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
index 92e4079..88b2dcf 100644
--- a/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.wst.server.ui; singleton:=true
-Bundle-Version: 1.1.6.qualifier
+Bundle-Version: 1.1.7.qualifier
 Bundle-Activator: org.eclipse.wst.server.ui.internal.ServerUIPlugin
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.xml b/plugins/org.eclipse.wst.server.ui/plugin.xml
index 75647be..15c6c8c 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.xml
+++ b/plugins/org.eclipse.wst.server.ui/plugin.xml
@@ -503,5 +503,12 @@
         id="org.eclipse.wst.server.ui.launchable.adapter.default"
         priority="-999999"/>
 </extension>
+<extension
+      point="org.eclipse.wst.server.core.saveEditorPrompter">
+   <saveEditorPrompter
+         class="org.eclipse.wst.server.ui.internal.SaveEditorPrompter"
+         id="org.eclipse.wst.server.ui.saveEditorPrompter1">
+   </saveEditorPrompter>
+</extension>
 
 </plugin>
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/SaveEditorPrompter.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/SaveEditorPrompter.java
new file mode 100644
index 0000000..ccd204a
--- /dev/null
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/SaveEditorPrompter.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.server.ui.internal;
+
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+
+public class SaveEditorPrompter extends
+		org.eclipse.wst.server.core.internal.SaveEditorPrompter { 
+	
+	private String cachedSaveBeforeLaunch;
+	
+	@Override
+	public void saveAllEditors() {
+		IWorkbench w = PlatformUI.getWorkbench();
+		String saveBeforeLaunch = DebugUITools.getPreferenceStore().getString(org.eclipse.debug.internal.ui.IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH);
+		if (saveBeforeLaunch.equalsIgnoreCase(org.eclipse.jface.dialogs.MessageDialogWithToggle.ALWAYS)){
+			Display d =PlatformUI.getWorkbench().getDisplay();
+			d.asyncExec(new SaveAllEditorsRunnable(w,false));
+		}
+		else if (saveBeforeLaunch.equalsIgnoreCase(org.eclipse.jface.dialogs.MessageDialogWithToggle.PROMPT)){
+			Display d =PlatformUI.getWorkbench().getDisplay();
+			d.asyncExec(new SaveAllEditorsRunnable(w,true));
+		}
+	}
+	
+	private class SaveAllEditorsRunnable implements Runnable{
+		IWorkbench w;
+		boolean confirm;
+		public SaveAllEditorsRunnable(IWorkbench w, boolean confirm){
+			this.w = w;
+			this.confirm = confirm;
+		}
+		
+		public void run() {
+			w.saveAllEditors(confirm);
+		}
+	}
+		
+	/**
+	 * Sets <code>org.eclipse.debug.internal.ui.IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH</code> to 
+	 * the given value. The given value should be one of the following:
+	 * <ul>
+	 * <li><code>org.eclipse.jface.dialogs.MessageDialogWithToggle.ALWAYS</code></li>
+	 * <li><code>org.eclipse.jface.dialogs.MessageDialogWithToggle.NEVER</code></li>
+	 * <li><code>org.eclipse.jface.dialogs.MessageDialogWithToggle.PROMPT</code></li>
+	 * </ul>  
+	 * @see org.eclipse.jface.dialogs.MessageDialogWithToggle
+	 */
+	public String setDebugSaveBeforeLaunching(String newValue){
+		IPreferenceStore debugPrefs = DebugUITools.getPreferenceStore();
+		String oldValue = debugPrefs.getString(org.eclipse.debug.internal.ui.IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH);
+		debugPrefs.setValue(org.eclipse.debug.internal.ui.IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH, newValue);
+		return oldValue; 
+	}
+	
+	public void setDebugNeverSave(){
+		cachedSaveBeforeLaunch = setDebugSaveBeforeLaunching(org.eclipse.jface.dialogs.MessageDialogWithToggle.NEVER);
+	}
+	
+	public void setDebugOriginalValue(){
+		if (cachedSaveBeforeLaunch == null){
+			cachedSaveBeforeLaunch = org.eclipse.jface.dialogs.MessageDialogWithToggle.PROMPT;
+		}
+		setDebugSaveBeforeLaunching(cachedSaveBeforeLaunch);
+	}
+}