mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Implementation of the debugger's preference pages.
This commit is contained in:
parent
fa410d22c0
commit
ce345efa78
6 changed files with 240 additions and 0 deletions
|
@ -50,6 +50,26 @@ import org.eclipse.debug.core.model.IProcess;
|
||||||
*/
|
*/
|
||||||
public class CDebugModel
|
public class CDebugModel
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Preference key for default CDI request timeout value.
|
||||||
|
*/
|
||||||
|
public static final String PREF_REQUEST_TIMEOUT = getPluginIdentifier() + ".PREF_REQUEST_TIMEOUT"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default CDI request timeout when no preference is set.
|
||||||
|
*/
|
||||||
|
public static final int DEF_REQUEST_TIMEOUT = 10000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum value the CDI request timeout can have.
|
||||||
|
*/
|
||||||
|
public static final int MIN_REQUEST_TIMEOUT = 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum value the CDI request timeout can have.
|
||||||
|
*/
|
||||||
|
public static final int MAX_REQUEST_TIMEOUT = Integer.MAX_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CDebugModel.
|
* Constructor for CDebugModel.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,6 +12,7 @@ MemoryView.name=Memory
|
||||||
CDebuggerPage.name=C Debugger UI Page
|
CDebuggerPage.name=C Debugger UI Page
|
||||||
MemoryPreferencePage.name=Memory Views
|
MemoryPreferencePage.name=Memory Views
|
||||||
RegistersPreferencePage.name=Registers View
|
RegistersPreferencePage.name=Registers View
|
||||||
|
CDebugPreferencePage.name=Debug
|
||||||
|
|
||||||
RunMenu.label=&Run
|
RunMenu.label=&Run
|
||||||
DebugActionSet.label=C/C++ Debug
|
DebugActionSet.label=C/C++ Debug
|
||||||
|
|
|
@ -81,6 +81,12 @@
|
||||||
class="org.eclipse.cdt.debug.internal.ui.preferences.RegistersViewPreferencePage"
|
class="org.eclipse.cdt.debug.internal.ui.preferences.RegistersViewPreferencePage"
|
||||||
id="org.eclipse.cdt.debug.ui.RegistersViewPreferencePage">
|
id="org.eclipse.cdt.debug.ui.RegistersViewPreferencePage">
|
||||||
</page>
|
</page>
|
||||||
|
<page
|
||||||
|
name="%CDebugPreferencePage.name"
|
||||||
|
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
|
||||||
|
class="org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage"
|
||||||
|
id="org.eclipse.cdt.debug.ui.CDebugPreferencePage">
|
||||||
|
</page>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.actionSets">
|
point="org.eclipse.ui.actionSets">
|
||||||
|
|
|
@ -33,4 +33,5 @@ public interface ICDebugHelpContextIds
|
||||||
// Preference pages
|
// Preference pages
|
||||||
public static final String MEMORY_PREFERENCE_PAGE = PREFIX + "memory_preference_page_context"; //$NON-NLS-1$
|
public static final String MEMORY_PREFERENCE_PAGE = PREFIX + "memory_preference_page_context"; //$NON-NLS-1$
|
||||||
public static final String REGISTERS_PREFERENCE_PAGE = PREFIX + "registers_preference_page_context"; //$NON-NLS-1$
|
public static final String REGISTERS_PREFERENCE_PAGE = PREFIX + "registers_preference_page_context"; //$NON-NLS-1$
|
||||||
|
public static final String C_DEBUG_PREFERENCE_PAGE = PREFIX + "c_debug_preference_page_context"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,199 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.preferences;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
|
import org.eclipse.cdt.debug.core.CDebugModel;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||||
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
|
import org.eclipse.jface.preference.FieldEditor;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.jface.preference.IntegerFieldEditor;
|
||||||
|
import org.eclipse.jface.preference.PreferencePage;
|
||||||
|
import org.eclipse.jface.preference.StringFieldEditor;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Group;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
|
import org.eclipse.ui.help.WorkbenchHelp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Preference page for debug preferences that apply specifically to
|
||||||
|
* C/C++ Debugging.
|
||||||
|
*
|
||||||
|
* @since Oct 3, 2002
|
||||||
|
*/
|
||||||
|
public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
|
||||||
|
{
|
||||||
|
// Timeout preference widgets
|
||||||
|
private IntegerFieldEditor fTimeoutText;
|
||||||
|
|
||||||
|
private PropertyChangeListener fPropertyChangeListener;
|
||||||
|
|
||||||
|
protected class PropertyChangeListener implements IPropertyChangeListener
|
||||||
|
{
|
||||||
|
private boolean fHasStateChanged = false;
|
||||||
|
|
||||||
|
public void propertyChange( PropertyChangeEvent event )
|
||||||
|
{
|
||||||
|
if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_SHOW_HEX_VALUES ) )
|
||||||
|
{
|
||||||
|
fHasStateChanged = true;
|
||||||
|
}
|
||||||
|
else if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_SHOW_CHAR_VALUES ) )
|
||||||
|
{
|
||||||
|
fHasStateChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean hasStateChanged()
|
||||||
|
{
|
||||||
|
return fHasStateChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for CDebugPreferencePage.
|
||||||
|
*/
|
||||||
|
public CDebugPreferencePage()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
setPreferenceStore( CDebugUIPlugin.getDefault().getPreferenceStore() );
|
||||||
|
getPreferenceStore().addPropertyChangeListener( getPropertyChangeListener() );
|
||||||
|
setDescription( "General settings for C/C++ Debugging." );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
|
||||||
|
*/
|
||||||
|
protected Control createContents( Composite parent )
|
||||||
|
{
|
||||||
|
WorkbenchHelp.setHelp( getControl(), ICDebugHelpContextIds.C_DEBUG_PREFERENCE_PAGE );
|
||||||
|
|
||||||
|
//The main composite
|
||||||
|
Composite composite = new Composite( parent, SWT.NULL );
|
||||||
|
GridLayout layout = new GridLayout();
|
||||||
|
layout.numColumns = 1;
|
||||||
|
layout.marginHeight = 0;
|
||||||
|
layout.marginWidth = 0;
|
||||||
|
composite.setLayout( layout );
|
||||||
|
GridData data = new GridData();
|
||||||
|
data.verticalAlignment = GridData.FILL;
|
||||||
|
data.horizontalAlignment = GridData.FILL;
|
||||||
|
composite.setLayoutData( data );
|
||||||
|
|
||||||
|
Composite comp = createGroupComposite( composite, 1, "Communication" );
|
||||||
|
//Add in an intermediate composite to allow for spacing
|
||||||
|
Composite spacingComposite = new Composite( comp, SWT.NONE );
|
||||||
|
layout = new GridLayout();
|
||||||
|
spacingComposite.setLayout( layout );
|
||||||
|
data = new GridData( GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL );
|
||||||
|
data.horizontalSpan = 2;
|
||||||
|
spacingComposite.setLayoutData( data );
|
||||||
|
|
||||||
|
fTimeoutText = new IntegerFieldEditor( CDebugModel.PREF_REQUEST_TIMEOUT, "Debugger &timeout (ms):", spacingComposite );
|
||||||
|
fTimeoutText.setPreferenceStore( CDebugUIPlugin.getDefault().getPreferenceStore() );
|
||||||
|
fTimeoutText.setPreferencePage( this );
|
||||||
|
fTimeoutText.setValidateStrategy( StringFieldEditor.VALIDATE_ON_KEY_STROKE );
|
||||||
|
fTimeoutText.setValidRange( CDebugModel.MIN_REQUEST_TIMEOUT, CDebugModel.MAX_REQUEST_TIMEOUT );
|
||||||
|
String minValue = Integer.toString( CDebugModel.MIN_REQUEST_TIMEOUT );
|
||||||
|
String maxValue = Integer.toString( CDebugModel.MAX_REQUEST_TIMEOUT );
|
||||||
|
fTimeoutText.setErrorMessage( MessageFormat.format( "The valid value range is [{0},{1}].", new String[]{ minValue, maxValue } ) );
|
||||||
|
fTimeoutText.load();
|
||||||
|
fTimeoutText.setPropertyChangeListener(
|
||||||
|
new IPropertyChangeListener()
|
||||||
|
{
|
||||||
|
public void propertyChange( PropertyChangeEvent event )
|
||||||
|
{
|
||||||
|
if ( event.getProperty().equals( FieldEditor.IS_VALID ) )
|
||||||
|
setValid( fTimeoutText.isValid() );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
setValues();
|
||||||
|
|
||||||
|
return composite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates composite group and sets the default layout data.
|
||||||
|
*
|
||||||
|
* @param parent the parent of the new composite
|
||||||
|
* @param numColumns the number of columns for the new composite
|
||||||
|
* @param labelText the text label of the new composite
|
||||||
|
* @return the newly-created composite
|
||||||
|
*/
|
||||||
|
private Composite createGroupComposite( Composite parent, int numColumns, String labelText )
|
||||||
|
{
|
||||||
|
Group comp = new Group( parent, SWT.NONE );
|
||||||
|
//GridLayout
|
||||||
|
GridLayout layout = new GridLayout();
|
||||||
|
layout.numColumns = numColumns;
|
||||||
|
comp.setLayout( layout );
|
||||||
|
//GridData
|
||||||
|
GridData gd = new GridData();
|
||||||
|
gd.verticalAlignment = GridData.FILL;
|
||||||
|
gd.horizontalAlignment = GridData.FILL;
|
||||||
|
comp.setLayoutData( gd );
|
||||||
|
comp.setText( labelText );
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the values of the component widgets based on the
|
||||||
|
* values in the preference store
|
||||||
|
*/
|
||||||
|
private void setValues()
|
||||||
|
{
|
||||||
|
IPreferenceStore store = getPreferenceStore();
|
||||||
|
|
||||||
|
fTimeoutText.setStringValue( new Integer( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( CDebugModel.PREF_REQUEST_TIMEOUT ) ).toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(IWorkbench)
|
||||||
|
*/
|
||||||
|
public void init( IWorkbench workbench )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PropertyChangeListener getPropertyChangeListener()
|
||||||
|
{
|
||||||
|
if ( fPropertyChangeListener == null )
|
||||||
|
{
|
||||||
|
fPropertyChangeListener = new PropertyChangeListener();
|
||||||
|
}
|
||||||
|
return fPropertyChangeListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the default preferences for this page.
|
||||||
|
*/
|
||||||
|
public static void initDefaults(IPreferenceStore store)
|
||||||
|
{
|
||||||
|
store.setDefault( ICDebugPreferenceConstants.PREF_SHOW_HEX_VALUES, false );
|
||||||
|
store.setDefault( ICDebugPreferenceConstants.PREF_SHOW_CHAR_VALUES, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DialogPage#dispose()
|
||||||
|
*/
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
super.dispose();
|
||||||
|
getPreferenceStore().removePropertyChangeListener( getPropertyChangeListener() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.internal.ui.preferences;
|
package org.eclipse.cdt.debug.internal.ui.preferences;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.FontData;
|
import org.eclipse.swt.graphics.FontData;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
@ -78,4 +79,16 @@ public interface ICDebugPreferenceConstants
|
||||||
* The name of the font to use for the memory view
|
* The name of the font to use for the memory view
|
||||||
*/
|
*/
|
||||||
public static final String MEMORY_FONT = "Memory.font"; //$NON-NLS-1$
|
public static final String MEMORY_FONT = "Memory.font"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boolean preference controlling whether primitive types
|
||||||
|
* types display hexidecimal values.
|
||||||
|
*/
|
||||||
|
public static final String PREF_SHOW_HEX_VALUES = ICDebugUIConstants.PLUGIN_ID + "cDebug.showHexValues"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boolean preference controlling whether primitive types
|
||||||
|
* types display char values.
|
||||||
|
*/
|
||||||
|
public static final String PREF_SHOW_CHAR_VALUES = ICDebugUIConstants.PLUGIN_ID + "cDebug.showCharValues"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue