Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPreferencePage.java24
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java44
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java24
3 files changed, 67 insertions, 25 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPreferencePage.java
index 1fbede7fa..ad10907dc 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPreferencePage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPreferencePage.java
@@ -12,9 +12,12 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.help.WorkbenchHelp;
@@ -24,6 +27,8 @@ import org.eclipse.ui.help.WorkbenchHelp;
*/
public class DebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage, IDebugPreferenceConstants {
+ private RadioGroupFieldEditor fSaveRadioFieldEditor;
+
public DebugPreferencePage() {
super(GRID);
@@ -54,8 +59,9 @@ public class DebugPreferencePage extends FieldEditorPreferencePage implements IW
{"C&onfiguration-based", IDebugPreferenceConstants.LAUNCHING_STYLE_CONFIGURATIONS}
},
getFieldEditorParent()));
- addField(new BooleanFieldEditor(IDebugUIConstants.PREF_AUTO_BUILD_BEFORE_LAUNCH, DebugUIMessages.getString("DebugPreferencePage.auto_build_before_launch"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
addField(new BooleanFieldEditor(IDebugUIConstants.PREF_SINGLE_CLICK_LAUNCHING, DebugUIMessages.getString("DebugPreferencePage.Enable_&single-click_launching_1"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
+ createSaveBeforeLaunchEditors(getFieldEditorParent());
+ addField(new BooleanFieldEditor(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH, DebugUIMessages.getString("DebugPreferencePage.auto_build_before_launch"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
addField(new BooleanFieldEditor(IDebugUIConstants.PREF_AUTO_SHOW_DEBUG_VIEW, DebugUIMessages.getString("DebugPreferencePage.Show_Debug_Perspective_when_a_program_is_launched_in_de&bug_mode_1"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
addField(new BooleanFieldEditor(IDebugUIConstants.PREF_AUTO_SHOW_PROCESS_VIEW, DebugUIMessages.getString("DebugPreferencePage.Show_Debug_Perspective_when_a_program_is_launched_in_&run_mode_2"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
addField(new BooleanFieldEditor(IDebugUIConstants.PREF_AUTO_REMOVE_OLD_LAUNCHES, DebugUIMessages.getString("DebugPreferencePage.Remove_terminated_launches_when_a_new_launch_is_created_1"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
@@ -79,13 +85,27 @@ public class DebugPreferencePage extends FieldEditorPreferencePage implements IW
protected static void initDefaults(IPreferenceStore store) {
store.setDefault(IDebugPreferenceConstants.LAUNCHING_STYLE, IDebugPreferenceConstants.LAUNCHING_STYLE_CONFIGURATIONS);
- store.setDefault(IDebugUIConstants.PREF_AUTO_BUILD_BEFORE_LAUNCH, true);
store.setDefault(IDebugUIConstants.PREF_SINGLE_CLICK_LAUNCHING, false);
+
+
+ store.setDefault(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH, true);
+ store.setDefault(IDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH_RADIO, IDebugUIConstants.PREF_PROMPT_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH);
store.setDefault(IDebugUIConstants.PREF_AUTO_SHOW_DEBUG_VIEW, true);
store.setDefault(IDebugUIConstants.PREF_AUTO_SHOW_PROCESS_VIEW, true);
store.setDefault(IDebugUIConstants.PREF_AUTO_REMOVE_OLD_LAUNCHES, false);
store.setDefault(IDebugPreferenceConstants.VARIABLES_DETAIL_PANE_ORIENTATION, IDebugPreferenceConstants.VARIABLES_DETAIL_PANE_UNDERNEATH);
PreferenceConverter.setDefault(store, CHANGED_VARIABLE_RGB, new RGB(255, 0, 0));
}
+
+ private void createSaveBeforeLaunchEditors(Composite parent) {
+ fSaveRadioFieldEditor = new RadioGroupFieldEditor(IDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH_RADIO, "Save dirty editors before launching", 1,
+ new String[][] {{"Never", IDebugUIConstants.PREF_NEVER_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH},
+ {"Prompt", IDebugUIConstants.PREF_PROMPT_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH},
+ {"Auto-save", IDebugUIConstants.PREF_AUTOSAVE_DIRTY_EDITORS_BEFORE_LAUNCH}},
+ parent);
+ addField(fSaveRadioFieldEditor);
+
+
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
index 9be0b0f20..acb748f40 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
@@ -1455,13 +1455,13 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener,
*
* @return whether all saving was completed
*/
- protected static boolean saveAllPages() {
+ protected static boolean saveAllPages(boolean confirm) {
IWorkbench wb = getActiveWorkbenchWindow().getWorkbench();
IWorkbenchWindow[] windows = wb.getWorkbenchWindows();
for (int i = 0; i < windows.length; i++) {
IWorkbenchPage[] pages = windows[i].getPages();
for (int j = 0; j < pages.length; j++) {
- if (!pages[j].saveAllEditors(true)) {
+ if (!pages[j].saveAllEditors(confirm)) {
return false;
};
}
@@ -1470,28 +1470,32 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener,
}
/**
- * If the "build before launch" preference is on, save
- * and build. This prompts the user to save any editors
- * with unsaved changes. Returns whether the operation
- * succeeded.
- *
- * @return whether saving and building was completed
+ * Save & build the workspace according to the user-specified preferences. Return <code>false</code> if
+ * any problems were encountered, <code>true</code> otherwise.
*/
public static boolean saveAndBuild() {
- if (!getDefault().getPreferenceStore().getBoolean(IDebugUIConstants.PREF_AUTO_BUILD_BEFORE_LAUNCH)) {
- return true;
- }
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- if (workspace.isAutoBuilding()) {
- // if auto-building, saving will trigger a build for us
- return saveAllPages();
- }
+ boolean status = true;
+ String saveDirty = getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH_RADIO);
+ boolean buildBeforeLaunch = getDefault().getPreferenceStore().getBoolean(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH);
+ boolean autobuilding = ResourcesPlugin.getWorkspace().isAutoBuilding();
- // prompt for save and then do build if required
- if (saveAllPages()) {
- return doBuild();
+ // If we're ignoring dirty editors, check if we need to build
+ if (saveDirty.equals(IDebugUIConstants.PREF_NEVER_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH)) {
+ if (buildBeforeLaunch) {
+ return doBuild();
+ }
+ } else {
+ boolean prompt = false;
+ if (saveDirty.equals(IDebugUIConstants.PREF_PROMPT_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH)) {
+ prompt = true;
+ }
+ status = saveAllPages(prompt);
+ if (status && !autobuilding && buildBeforeLaunch) {
+ status = doBuild();
+ }
}
- return false;
+
+ return status;
}
private static boolean doBuild() {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
index 8e09d4194..c978ce714 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java
@@ -143,10 +143,28 @@ public interface IDebugUIConstants {
public static final String PREF_AUTO_SHOW_PROCESS_VIEW= PLUGIN_ID + ".auto_show_process_view"; //$NON-NLS-1$
/**
- * Boolean preference controlling automatic build before
- * launching a program.
+ * Boolean preference controlling whether a build is done before
+ * launching a program (if one is needed).
*/
- public static final String PREF_AUTO_BUILD_BEFORE_LAUNCH= PLUGIN_ID + ".auto_build_before_launch"; //$NON-NLS-1$
+ public static final String PREF_BUILD_BEFORE_LAUNCH= PLUGIN_ID + ".build_before_launch"; //$NON-NLS-1$
+ /**
+ * Identifier for the radio button group that consists of the following two preferences.
+ */
+ public static final String PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH_RADIO= PLUGIN_ID + ".save_dirty_editors_before_launch_radio"; //$NON-NLS-1$
+ /**
+ * Radio button preference specifying that dirty editors should be autosaved (no prompting)
+ * before launching.
+ */
+ public static final String PREF_AUTOSAVE_DIRTY_EDITORS_BEFORE_LAUNCH= PLUGIN_ID + ".auto_save_dirty_editors_before_launch"; //$NON-NLS-1$
+ /**
+ * Radio button preference specifying that dirty editors should cause a prompt to appear to the
+ * user asking if they wish to save.
+ */
+ public static final String PREF_PROMPT_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH= PLUGIN_ID + ".prompt_save_dirty_editors_before_launch"; //$NON-NLS-1$
+ /**
+ * Radio button preference specifyig that dirty editors should never be saved before launching.
+ */
+ public static final String PREF_NEVER_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH= PLUGIN_ID + ".never_save_dirty_editors_before_launch"; //$NON-NLS-1$
/**
* Boolean preference controlling automatic removal of terminated launches
* when a new launch is registered.

Back to the top