Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Kunter2012-03-07 09:33:31 -0500
committerMarc Khouzam2012-03-07 09:33:31 -0500
commitbaeccceba692449b8bbb77bc851e556820f4fcfd (patch)
treef7418e228f2cdbb8846e21879d7d36588445d5d4 /debug/org.eclipse.cdt.debug.ui/src/org
parent0a9a95adcd3ba273c1b67a11483d19d435f2b2f2 (diff)
downloadorg.eclipse.cdt-baeccceba692449b8bbb77bc851e556820f4fcfd.tar.gz
org.eclipse.cdt-baeccceba692449b8bbb77bc851e556820f4fcfd.tar.xz
org.eclipse.cdt-baeccceba692449b8bbb77bc851e556820f4fcfd.zip
Bug 370462 - Improving the debug preferences - add support for different charsets and unify DSF and CDI debug preferences
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui/src/org')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java108
1 files changed, 80 insertions, 28 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java
index a58f8e2867..663281b89e 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java
@@ -20,6 +20,9 @@ import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDebugView;
import org.eclipse.jface.preference.FieldEditor;
@@ -45,6 +48,7 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.ide.dialogs.EncodingFieldEditor;
+import org.osgi.service.prefs.BackingStoreException;
/**
* Preference page for debug preferences that apply specifically to C/C++ Debugging.
@@ -172,30 +176,60 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
* Set the values of the component widgets based on the values in the preference store
*/
private void setValues() {
- // Number format combos
- fVariableFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT ) ) );
- fExpressionFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) );
- fRegisterFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
+ // Set the number format combo boxes.
+ fVariableFormatCombo.select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, ICDIFormat.NATURAL, null)));
+ fExpressionFormatCombo.select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, ICDIFormat.NATURAL, null)));
+ fRegisterFormatCombo.select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, ICDIFormat.NATURAL, null)));
- // Charset editors
+
+ // Set the charset editors.
+
+ // Create a temporary preference store.
PreferenceStore ps = new PreferenceStore();
- ps.setDefault(ICDebugConstants.PREF_DEBUG_CHARSET, CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString(ICDebugConstants.PREF_DEBUG_CHARSET));
- ps.setValue(ICDebugConstants.PREF_DEBUG_CHARSET, CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_DEBUG_CHARSET));
+ // Get the default charset and the default wide charset.
+ String defaultCharset = DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).get(ICDebugConstants.PREF_DEBUG_CHARSET, null);
+ if (defaultCharset != null) {
+ ps.setDefault(ICDebugConstants.PREF_DEBUG_CHARSET, defaultCharset);
+ }
+ String defaultWideCharset = DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).get(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, null);
+ if (defaultWideCharset != null) {
+ ps.setDefault(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, defaultWideCharset);
+ }
+
+ // Get the charset and the wide charset. If they're unset, use the default instead.
+ // Note that we have to call the setValue() function of the PreferenceStore even if we
+ // want to use the default. This is to ensure proper display of the encoding field editor.
+ String charset = InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).get(ICDebugConstants.PREF_DEBUG_CHARSET, null);
+ if (charset != null) {
+ ps.setValue(ICDebugConstants.PREF_DEBUG_CHARSET, charset);
+ } else if (defaultCharset != null) {
+ ps.setValue(ICDebugConstants.PREF_DEBUG_CHARSET, defaultCharset);
+ }
+ String wideCharset = InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).get(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, null);
+ if (wideCharset != null) {
+ ps.setValue(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, wideCharset);
+ } else if (defaultWideCharset != null) {
+ ps.setValue(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, defaultWideCharset);
+ }
+
+ // Initialize the encoding field editors with the values from the preference store.
fCharsetEditor.setPreferenceStore(ps);
fCharsetEditor.load();
- if (CDebugCorePlugin.getDefault().getPluginPreferences().isDefault(ICDebugConstants.PREF_DEBUG_CHARSET))
- fCharsetEditor.loadDefault();
-
- ps.setDefault(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET));
- ps.setValue(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET));
fWideCharsetEditor.setPreferenceStore(ps);
fWideCharsetEditor.load();
- if (CDebugCorePlugin.getDefault().getPluginPreferences().isDefault(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET))
+
+ // Tell the encoding field editors to check the "Default" option if we're currently using the default values.
+ if (charset == null) {
+ fCharsetEditor.loadDefault();
+ }
+ if (wideCharset == null) {
fWideCharsetEditor.loadDefault();
+ }
+
- // Others
- fShowBinarySourceFilesButton.setSelection( CCorePlugin.getDefault().getPluginPreferences().getBoolean( CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES ) );
+ // Set the values for the remaining preferences.
+ fShowBinarySourceFilesButton.setSelection(Platform.getPreferencesService().getBoolean(CCorePlugin.PLUGIN_ID, CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, true, null));
}
/*
@@ -302,8 +336,13 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
if ( getPropertyChangeListener().hasStateChanged() ) {
refreshViews();
}
- CDebugUIPlugin.getDefault().savePluginPreferences();
- CDebugCorePlugin.getDefault().savePluginPreferences();
+
+ try {
+ InstanceScope.INSTANCE.getNode(CDebugUIPlugin.PLUGIN_ID).flush();
+ InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).flush();
+ } catch (BackingStoreException e) {
+ // No operation
+ }
return true;
}
@@ -350,17 +389,29 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
* Store the preference values based on the state of the component widgets
*/
private void storeValues() {
- CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, getFormatId( fVariableFormatCombo.getSelectionIndex() ) );
- CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, getFormatId( fExpressionFormatCombo.getSelectionIndex() ) );
- CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, getFormatId( fRegisterFormatCombo.getSelectionIndex() ) );
+ // Store the number formats.
+ InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).putInt(ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, getFormatId(fVariableFormatCombo.getSelectionIndex()));
+ InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).putInt(ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, getFormatId(fExpressionFormatCombo.getSelectionIndex()));
+ InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).putInt(ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, getFormatId(fRegisterFormatCombo.getSelectionIndex()));
- fCharsetEditor.store();
- CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_DEBUG_CHARSET, fCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_CHARSET));
+ // Store the charset.
+ if (fCharsetEditor.presentsDefaultValue()) {
+ InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).remove(ICDebugConstants.PREF_DEBUG_CHARSET);
+ } else {
+ fCharsetEditor.store();
+ InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).put(ICDebugConstants.PREF_DEBUG_CHARSET, fCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_CHARSET));
+ }
- fWideCharsetEditor.store();
- CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, fWideCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET));
+ // Store the wide charset.
+ if (fWideCharsetEditor.presentsDefaultValue()) {
+ InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).remove(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET);
+ } else {
+ fWideCharsetEditor.store();
+ InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).put(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, fWideCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET));
+ }
- CCorePlugin.getDefault().getPluginPreferences().setValue( CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, fShowBinarySourceFilesButton.getSelection() );
+ // Store the other preferences.
+ InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).putBoolean(CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, fShowBinarySourceFilesButton.getSelection());
}
/**
@@ -375,11 +426,12 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
}
private void setDefaultValues() {
- fVariableFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT ) ) );
- fExpressionFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) );
- fRegisterFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
+ fVariableFormatCombo.select(getFormatIndex(DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).getInt(ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, ICDIFormat.NATURAL)));
+ fExpressionFormatCombo.select(getFormatIndex(DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).getInt(ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, ICDIFormat.NATURAL)));
+ fRegisterFormatCombo.select(getFormatIndex(DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).getInt(ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, ICDIFormat.NATURAL)));
fCharsetEditor.loadDefault();
fWideCharsetEditor.loadDefault();
+ fShowBinarySourceFilesButton.setSelection(DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).getBoolean(CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, true));
}
private static int getFormatId( int index ) {

Back to the top