mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Bug 370462 - Improving the debug preferences - add support for different charsets and unify DSF and CDI debug preferences
This commit is contained in:
parent
0a9a95adcd
commit
baeccceba6
3 changed files with 97 additions and 40 deletions
|
@ -55,7 +55,7 @@ public interface ICDebugConstants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deprecated id for the charset used for decoding wchar_t type strings.
|
* Deprecated id for the charset used for decoding wchar_t type strings.
|
||||||
* Replaced by ICDebugConstants.PREF_WIDE_CHARSET.
|
* Replaced by ICDebugConstants.PREF_DEBUG_WIDE_CHARSET.
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|
|
@ -19,6 +19,8 @@ import org.eclipse.cdt.debug.core.ICDebugConstants;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
|
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||||
|
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||||
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default preference value initializer for <code>CDebugCorePlugin</code>.
|
* Default preference value initializer for <code>CDebugCorePlugin</code>.
|
||||||
|
@ -37,15 +39,18 @@ public class CDebugCorePreferenceInitializer extends AbstractPreferenceInitializ
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initializeDefaultPreferences() {
|
public void initializeDefaultPreferences() {
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_MAX_NUMBER_OF_INSTRUCTIONS, ICDebugConstants.DEF_NUMBER_OF_INSTRUCTIONS );
|
IEclipsePreferences defaultPreferences = DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID);
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, ICDIFormat.NATURAL );
|
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, ICDIFormat.NATURAL );
|
defaultPreferences.putInt(ICDebugConstants.PREF_MAX_NUMBER_OF_INSTRUCTIONS, ICDebugConstants.DEF_NUMBER_OF_INSTRUCTIONS);
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, ICDIFormat.NATURAL );
|
defaultPreferences.putInt(ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, ICDIFormat.NATURAL);
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_DEBUG_CHARSET, Charset.defaultCharset().name() );
|
defaultPreferences.putInt(ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, ICDIFormat.NATURAL);
|
||||||
if (Platform.getOS().equals(Platform.OS_WIN32))
|
defaultPreferences.putInt(ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, ICDIFormat.NATURAL);
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, "UTF-16"); //$NON-NLS-1$
|
defaultPreferences.put(ICDebugConstants.PREF_DEBUG_CHARSET, Charset.defaultCharset().name());
|
||||||
else
|
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, "UTF-32"); //$NON-NLS-1$
|
defaultPreferences.put(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, "UTF-16"); //$NON-NLS-1$
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_INSTRUCTION_STEP_MODE_ON, false );
|
} else {
|
||||||
|
defaultPreferences.put(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, "UTF-32"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
defaultPreferences.putBoolean(ICDebugConstants.PREF_INSTRUCTION_STEP_MODE_ON, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.internal.ui.ICDebugHelpContextIds;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
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.IDebugUIConstants;
|
||||||
import org.eclipse.debug.ui.IDebugView;
|
import org.eclipse.debug.ui.IDebugView;
|
||||||
import org.eclipse.jface.preference.FieldEditor;
|
import org.eclipse.jface.preference.FieldEditor;
|
||||||
|
@ -45,6 +48,7 @@ import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.ide.dialogs.EncodingFieldEditor;
|
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.
|
* 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
|
* Set the values of the component widgets based on the values in the preference store
|
||||||
*/
|
*/
|
||||||
private void setValues() {
|
private void setValues() {
|
||||||
// Number format combos
|
// Set the number format combo boxes.
|
||||||
fVariableFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT ) ) );
|
fVariableFormatCombo.select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, ICDIFormat.NATURAL, null)));
|
||||||
fExpressionFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) );
|
fExpressionFormatCombo.select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, ICDIFormat.NATURAL, null)));
|
||||||
fRegisterFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
|
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();
|
PreferenceStore ps = new PreferenceStore();
|
||||||
|
|
||||||
ps.setDefault(ICDebugConstants.PREF_DEBUG_CHARSET, CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString(ICDebugConstants.PREF_DEBUG_CHARSET));
|
// Get the default charset and the default wide charset.
|
||||||
ps.setValue(ICDebugConstants.PREF_DEBUG_CHARSET, CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_DEBUG_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.setPreferenceStore(ps);
|
||||||
fCharsetEditor.load();
|
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.setPreferenceStore(ps);
|
||||||
fWideCharsetEditor.load();
|
fWideCharsetEditor.load();
|
||||||
if (CDebugCorePlugin.getDefault().getPluginPreferences().isDefault(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET))
|
|
||||||
fWideCharsetEditor.loadDefault();
|
|
||||||
|
|
||||||
// Others
|
// Tell the encoding field editors to check the "Default" option if we're currently using the default values.
|
||||||
fShowBinarySourceFilesButton.setSelection( CCorePlugin.getDefault().getPluginPreferences().getBoolean( CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES ) );
|
if (charset == null) {
|
||||||
|
fCharsetEditor.loadDefault();
|
||||||
|
}
|
||||||
|
if (wideCharset == null) {
|
||||||
|
fWideCharsetEditor.loadDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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() ) {
|
if ( getPropertyChangeListener().hasStateChanged() ) {
|
||||||
refreshViews();
|
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;
|
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
|
* Store the preference values based on the state of the component widgets
|
||||||
*/
|
*/
|
||||||
private void storeValues() {
|
private void storeValues() {
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, getFormatId( fVariableFormatCombo.getSelectionIndex() ) );
|
// Store the number formats.
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, getFormatId( fExpressionFormatCombo.getSelectionIndex() ) );
|
InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).putInt(ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, getFormatId(fVariableFormatCombo.getSelectionIndex()));
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, getFormatId( fRegisterFormatCombo.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()));
|
||||||
|
|
||||||
|
// Store the charset.
|
||||||
|
if (fCharsetEditor.presentsDefaultValue()) {
|
||||||
|
InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).remove(ICDebugConstants.PREF_DEBUG_CHARSET);
|
||||||
|
} else {
|
||||||
fCharsetEditor.store();
|
fCharsetEditor.store();
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_DEBUG_CHARSET, fCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_CHARSET));
|
InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).put(ICDebugConstants.PREF_DEBUG_CHARSET, fCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_CHARSET));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the wide charset.
|
||||||
|
if (fWideCharsetEditor.presentsDefaultValue()) {
|
||||||
|
InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).remove(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET);
|
||||||
|
} else {
|
||||||
fWideCharsetEditor.store();
|
fWideCharsetEditor.store();
|
||||||
CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, fWideCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET));
|
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() {
|
private void setDefaultValues() {
|
||||||
fVariableFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT ) ) );
|
fVariableFormatCombo.select(getFormatIndex(DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).getInt(ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, ICDIFormat.NATURAL)));
|
||||||
fExpressionFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) );
|
fExpressionFormatCombo.select(getFormatIndex(DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).getInt(ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, ICDIFormat.NATURAL)));
|
||||||
fRegisterFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
|
fRegisterFormatCombo.select(getFormatIndex(DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID).getInt(ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, ICDIFormat.NATURAL)));
|
||||||
fCharsetEditor.loadDefault();
|
fCharsetEditor.loadDefault();
|
||||||
fWideCharsetEditor.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 ) {
|
private static int getFormatId( int index ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue