1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-21 16:05:25 +02:00

Implementation of the breakpoint preference page.

This commit is contained in:
Mikhail Khodjaiants 2002-08-27 23:04:30 +00:00
parent b6d9b58b4c
commit 5321f78ce1
2 changed files with 616 additions and 0 deletions

View file

@ -0,0 +1,285 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.ICBreakpoint;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.resource.ImageDescriptor;
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.Label;
import org.eclipse.swt.widgets.Text;
/**
*
* The preference page that is used to present the properties of a breakpoint as
* preferences. A CBreakpointPreferenceStore is used to interface between this
* page and the breakpoint.
*
* @since Aug 27, 2002
*/
public class CBreakpointPreferencePage extends FieldEditorPreferencePage
{
class BreakpointIntegerFieldEditor extends IntegerFieldEditor
{
public BreakpointIntegerFieldEditor( String name, String labelText, Composite parent )
{
super( name, labelText, parent );
setErrorMessage( "Ignore count must be a positive integer" );
}
/**
* @see IntegerFieldEditor#checkState()
*/
protected boolean checkState()
{
Text control = getTextControl();
if ( !control.isEnabled() )
{
clearErrorMessage();
return true;
}
return super.checkState();
}
/**
* Overrode here to be package visible.
*/
protected void refreshValidState()
{
super.refreshValidState();
}
/**
* Only store if the text control is enabled
* @see FieldEditor#doStore()
*/
protected void doStore()
{
Text text = getTextControl();
if ( text.isEnabled() )
{
super.doStore();
}
}
/**
* Clears the error message from the message line if the error
* message is the error message from this field editor.
*/
protected void clearErrorMessage()
{
if ( getPreferencePage() != null )
{
String message = getPreferencePage().getErrorMessage();
if ( message != null )
{
if ( getErrorMessage().equals( message ) )
{
super.clearErrorMessage();
}
}
else
{
super.clearErrorMessage();
}
}
}
}
class BreakpointStringFieldEditor extends StringFieldEditor
{
public BreakpointStringFieldEditor( String name, String labelText, Composite parent )
{
super( name, labelText, parent );
}
/**
* @see StringFieldEditor#checkState()
*/
protected boolean checkState()
{
Text control = getTextControl();
if ( !control.isEnabled() )
{
clearErrorMessage();
return true;
}
return super.checkState();
}
protected void doStore()
{
Text text = getTextControl();
if ( text.isEnabled() )
{
super.doStore();
}
}
/**
* @see FieldEditor#refreshValidState()
*/
protected void refreshValidState()
{
super.refreshValidState();
}
/**
* Clears the error message from the message line if the error
* message is the error message from this field editor.
*/
protected void clearErrorMessage()
{
if ( getPreferencePage() != null )
{
String message = getPreferencePage().getErrorMessage();
if ( message != null )
{
if ( getErrorMessage().equals( message ) )
{
super.clearErrorMessage();
}
}
else
{
super.clearErrorMessage();
}
}
}
}
class LabelFieldEditor extends FieldEditor
{
private Label fTitleLabel;
private Label fValueLabel;
private Composite fBasicComposite;
private String fValue;
private String fTitle;
public LabelFieldEditor( Composite parent, String title, String value )
{
fValue = value;
fTitle = title;
this.createControl( parent );
}
protected void adjustForNumColumns( int numColumns )
{
((GridData)fBasicComposite.getLayoutData()).horizontalSpan = numColumns;
}
protected void doFillIntoGrid( Composite parent, int numColumns )
{
fBasicComposite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.numColumns = 2;
fBasicComposite.setLayout( layout );
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
fBasicComposite.setLayoutData( data );
fTitleLabel = new Label( fBasicComposite, SWT.NONE );
fTitleLabel.setText( fTitle );
GridData gd = new GridData();
gd.verticalAlignment = SWT.TOP;
fTitleLabel.setLayoutData( gd );
fValueLabel = new Label( fBasicComposite, SWT.WRAP );
fValueLabel.setText( fValue );
gd = new GridData();
fValueLabel.setLayoutData( gd );
}
public int getNumberOfControls()
{
return 1;
}
/**
* The label field editor is only used to present a text label
* on a preference page.
*/
protected void doLoad()
{
}
protected void doLoadDefault()
{
}
protected void doStore()
{
}
}
private Text fConditionTextControl;
private BreakpointStringFieldEditor fCondition;
private Text fIgnoreCountTextControl;
private BreakpointIntegerFieldEditor fIgnoreCount;
private ICBreakpoint fBreakpoint;
/**
* Constructor for CBreakpointPreferencePage.
* @param style
*/
public CBreakpointPreferencePage( ICBreakpoint breakpoint )
{
super( GRID );
setBreakpoint( breakpoint );
}
/**
* Constructor for CBreakpointPreferencePage.
* @param title
* @param style
*/
public CBreakpointPreferencePage(String title, int style)
{
super(title, style);
}
/**
* Constructor for CBreakpointPreferencePage.
* @param title
* @param image
* @param style
*/
public CBreakpointPreferencePage(
String title,
ImageDescriptor image,
int style)
{
super(title, image, style);
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
protected void createFieldEditors()
{
}
protected ICBreakpoint getBreakpoint()
{
return fBreakpoint;
}
protected void setBreakpoint( ICBreakpoint breakpoint )
{
fBreakpoint = breakpoint;
}
}

View file

@ -0,0 +1,331 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.HashMap;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent;
/**
*
* A preference store that presents the state of the properties
* of a C/C++ breakpoint. Default settings are not supported.
*
* @since Aug 27, 2002
*/
public class CBreakpointPreferenceStore implements IPreferenceStore
{
protected final static String ENABLED = "ENABLED"; //$NON-NLS-1$
protected final static String CONDITION = "CONDITION"; //$NON-NLS-1$
protected final static String IGNORE_COUNT = "IGNORE_COUNT"; //$NON-NLS-1$
protected HashMap fProperties;
private boolean fIsDirty = false;
private ListenerList fListeners;
/**
* Constructor for CBreakpointPreferenceStore.
*/
public CBreakpointPreferenceStore()
{
fProperties = new HashMap( 3 );
fListeners = new ListenerList();
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener)
*/
public void addPropertyChangeListener( IPropertyChangeListener listener )
{
fListeners.add( listener );
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#contains(String)
*/
public boolean contains( String name )
{
return fProperties.containsKey( name );
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(String, Object, Object)
*/
public void firePropertyChangeEvent( String name, Object oldValue, Object newValue )
{
Object[] listeners = fListeners.getListeners();
if ( listeners.length > 0 && (oldValue == null || !oldValue.equals( newValue ) ) )
{
PropertyChangeEvent pe = new PropertyChangeEvent( this, name, oldValue, newValue );
for ( int i = 0; i < listeners.length; ++i )
{
IPropertyChangeListener l = (IPropertyChangeListener)listeners[i];
l.propertyChange( pe );
}
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(String)
*/
public boolean getBoolean( String name )
{
Object b = fProperties.get( name );
if ( b instanceof Boolean )
{
return ((Boolean)b).booleanValue();
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(String)
*/
public boolean getDefaultBoolean( String name )
{
return false;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(String)
*/
public double getDefaultDouble( String name )
{
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(String)
*/
public float getDefaultFloat( String name )
{
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(String)
*/
public int getDefaultInt( String name )
{
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(String)
*/
public long getDefaultLong( String name )
{
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(String)
*/
public String getDefaultString( String name )
{
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getDouble(String)
*/
public double getDouble( String name )
{
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getFloat(String)
*/
public float getFloat( String name )
{
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getInt(String)
*/
public int getInt( String name )
{
Object i = fProperties.get( name );
if ( i instanceof Integer )
{
return ((Integer)i).intValue();
}
return 1;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getLong(String)
*/
public long getLong( String name )
{
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#getString(String)
*/
public String getString( String name )
{
Object str = fProperties.get( name );
if ( str instanceof String )
{
return (String)str;
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#isDefault(String)
*/
public boolean isDefault( String name )
{
return false;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#needsSaving()
*/
public boolean needsSaving()
{
return fIsDirty;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#putValue(String, String)
*/
public void putValue( String name, String newValue )
{
Object oldValue = fProperties.get( name );
if ( oldValue == null || !oldValue.equals( newValue ) )
{
fProperties.put( name, newValue );
setDirty( true );
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener)
*/
public void removePropertyChangeListener( IPropertyChangeListener listener )
{
fListeners.remove( listener );
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, double)
*/
public void setDefault( String name, double value )
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, float)
*/
public void setDefault( String name, float value )
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, int)
*/
public void setDefault( String name, int value )
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, long)
*/
public void setDefault( String name, long value )
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, String)
*/
public void setDefault( String name, String defaultObject )
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, boolean)
*/
public void setDefault( String name, boolean value )
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(String)
*/
public void setToDefault( String name )
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, double)
*/
public void setValue( String name, double value )
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, float)
*/
public void setValue( String name, float value )
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, int)
*/
public void setValue( String name, int newValue )
{
int oldValue = getInt( name );
if ( oldValue != newValue )
{
fProperties.put( name, new Integer( newValue ) );
setDirty( true );
firePropertyChangeEvent( name, new Integer( oldValue ), new Integer( newValue ) );
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, long)
*/
public void setValue( String name, long value )
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, String)
*/
public void setValue(String name, String value)
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, boolean)
*/
public void setValue( String name, boolean newValue )
{
boolean oldValue = getBoolean( name );
if ( oldValue != newValue )
{
fProperties.put( name, new Boolean( newValue ) );
setDirty(true);
firePropertyChangeEvent( name, new Boolean( oldValue ), new Boolean( newValue ) );
}
}
protected void setDirty( boolean isDirty )
{
fIsDirty = isDirty;
}
}