1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Replaced the "Breakpoint Properties" dialog by standard property pages.

This commit is contained in:
Mikhail Khodjaiants 2004-08-24 20:06:04 +00:00
parent 9dbce05b79
commit 2c8471ce9c
10 changed files with 375 additions and 751 deletions

View file

@ -1,3 +1,15 @@
2004-08-24 Mikhail Khodjaiants
Replaced the "Breakpoint Properties" dialog by standard property pages.
* CBreakpointPreferenceStore.java
* CBreakpointPropertiesAction.java
* CBreakpointPropertiesRulerAction.java
* CBreakpointPropertiesRulerActionDelegate.java
* CBreakpointPreferencePage.java renamed to CBreakpointPropertyPage.java
* CBreakpointPropertiesDialog.java: removed
* plugin.xml
* plugin.properties
* ActionMessages.properties
2004-08-12 Mikhail Khodjaiants
Fix for bug 70453. Linux: error exiting Eclipse on Linux RedHat or SuSe Enterprise Server 9.
Applied modified patch from Sean Evoy.

View file

@ -119,3 +119,5 @@ DebugTextHover.description=Shows the value of the expression selected in the deb
DebuggingCContext.name=Debugging C/C++
DebuggingCContext.description=Debugging C/C++ Programs
CommonBreakpointPage.label=Common

View file

@ -1071,6 +1071,12 @@
class="org.eclipse.cdt.debug.ui.sourcelookup.SourcePropertyPage"
id="org.eclipse.cdt.debug.ui.sourcelookup.SourcePropertyPage">
</page>
<page
adaptable="true"
objectClass="org.eclipse.cdt.debug.core.model.ICBreakpoint"
class="org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertyPage"
name="%CommonBreakpointPage.label"
id="org.eclipse.cdt.debug.ui.propertypages.breakpoint.common"/>
</extension>
<extension
id="org.eclipse.cdt.debug.ui.editors"

View file

@ -102,28 +102,30 @@ MemorySizeAction.0={0, number, integer} {0, choice, 1\#byte|2\#bytes}
MemorySizeAction.1=Unable to change memory unit size.
MemoryFormatAction.0=Unable to change the format.
MemoryFormatAction.1=Hexadecimal
MemoryFormatAction.2=Signed_Decimal
MemoryFormatAction.3=Unsigned_Decimal
MemoryFormatAction.2=Signed Decimal
MemoryFormatAction.3=Unsigned Decimal
MemoryNumberOfColumnAction.0={0, number, integer} {0, choice, 0\#columns|1\#column|2\#columns}
MemoryNumberOfColumnAction.1=Unable to change the column number.
CBreakpointPreferencePage.0=Ignore count must be a positive integer
CBreakpointPreferencePage.1=Not available
CBreakpointPreferencePage.2=Function name:
CBreakpointPreferencePage.3=C/C++ Function Breakpoint Properties
CBreakpointPreferencePage.4=Not available
CBreakpointPreferencePage.5=Address:
CBreakpointPreferencePage.6=C/C++ Address Breakpoint Properties
CBreakpointPreferencePage.7=File:
CBreakpointPreferencePage.8=C/C++ Line Breakpoint Properties
CBreakpointPreferencePage.9=Line_Number:
CBreakpointPreferencePage.10=Project:
CBreakpointPreferencePage.11=C/C++ Read Watchpoint Properties
CBreakpointPreferencePage.12=C/C++ Watchpoint Properties
CBreakpointPreferencePage.13=C/C++ Access Watchpoint Properties
CBreakpointPreferencePage.14=Expression To Watch:
CBreakpointPreferencePage.15=&Condition
CBreakpointPreferencePage.16=Invalid_condition.
CBreakpointPreferencePage.17=&Ignore Count:
CBreakpointPropertyPage.0=Ignore count must be a nonnegative integer
CBreakpointPropertyPage.1=Not available
CBreakpointPropertyPage.2=Function name:
CBreakpointPropertyPage.3=C/C++ function breakpoint
CBreakpointPropertyPage.4=Not available
CBreakpointPropertyPage.5=Address:
CBreakpointPropertyPage.6=C/C++ address breakpoint
CBreakpointPropertyPage.7=File:
CBreakpointPropertyPage.8=C/C++ line breakpoint
CBreakpointPropertyPage.9=Line number:
CBreakpointPropertyPage.10=Project:
CBreakpointPropertyPage.11=C/C++ read watchpoint
CBreakpointPropertyPage.12=C/C++ watchpoint
CBreakpointPropertyPage.13=C/C++ access watchpoint
CBreakpointPropertyPage.14=Expression to watch:
CBreakpointPropertyPage.15=&Condition:
CBreakpointPropertyPage.16=Invalid condition.
CBreakpointPropertyPage.17=&Ignore count:
CBreakpointPropertyPage.18=Type:
CBreakpointPropertyPage.19=Enabled
AddWatchpointActionDelegate.0=Cannot add watchpoint.
AddWatchpointDialog.0=Add Watchpoint
AddWatchpointDialog.1=Expression to watch:

View file

@ -11,333 +11,353 @@
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
* A preference store that presents the state of the properties of a C/C++ breakpoint. Default settings are not supported.
*/
public class CBreakpointPreferenceStore implements IPreferenceStore
{
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 boolean fIsDirty = false;
private ListenerList fListeners;
/**
* Constructor for CBreakpointPreferenceStore.
*/
public CBreakpointPreferenceStore()
{
public CBreakpointPreferenceStore() {
fProperties = new HashMap( 3 );
fListeners = new ListenerList();
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener)
*/
public void addPropertyChangeListener( IPropertyChangeListener listener )
{
public void addPropertyChangeListener( IPropertyChangeListener listener ) {
fListeners.add( listener );
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#contains(String)
*/
public boolean contains( String name )
{
public boolean contains( String name ) {
return fProperties.containsKey( name );
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(String, Object, Object)
*/
public void firePropertyChangeEvent( String name, Object oldValue, Object newValue )
{
public void firePropertyChangeEvent( String name, Object oldValue, Object newValue ) {
Object[] listeners = fListeners.getListeners();
if ( listeners.length > 0 && (oldValue == null || !oldValue.equals( newValue ) ) )
{
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 )
{
for( int i = 0; i < listeners.length; ++i ) {
IPropertyChangeListener l = (IPropertyChangeListener)listeners[i];
l.propertyChange( pe );
}
}
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(String)
*/
public boolean getBoolean( String name )
{
public boolean getBoolean( String name ) {
Object b = fProperties.get( name );
if ( b instanceof Boolean )
{
if ( b instanceof Boolean ) {
return ((Boolean)b).booleanValue();
}
return false;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(String)
*/
public boolean getDefaultBoolean( String name )
{
public boolean getDefaultBoolean( String name ) {
return false;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(String)
*/
public double getDefaultDouble( String name )
{
public double getDefaultDouble( String name ) {
return 0;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(String)
*/
public float getDefaultFloat( String name )
{
public float getDefaultFloat( String name ) {
return 0;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(String)
*/
public int getDefaultInt( String name )
{
public int getDefaultInt( String name ) {
return 0;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(String)
*/
public long getDefaultLong( String name )
{
public long getDefaultLong( String name ) {
return 0;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(String)
*/
public String getDefaultString( String name )
{
public String getDefaultString( String name ) {
return null;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getDouble(String)
*/
public double getDouble( String name )
{
public double getDouble( String name ) {
return 0;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getFloat(String)
*/
public float getFloat( String name )
{
public float getFloat( String name ) {
return 0;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getInt(String)
*/
public int getInt( String name )
{
public int getInt( String name ) {
Object i = fProperties.get( name );
if ( i instanceof Integer )
{
if ( i instanceof Integer ) {
return ((Integer)i).intValue();
}
return 1;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getLong(String)
*/
public long getLong( String name )
{
public long getLong( String name ) {
return 0;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#getString(String)
*/
public String getString( String name )
{
public String getString( String name ) {
Object str = fProperties.get( name );
if ( str instanceof String )
{
if ( str instanceof String ) {
return (String)str;
}
return null;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#isDefault(String)
*/
public boolean isDefault( String name )
{
public boolean isDefault( String name ) {
return false;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#needsSaving()
*/
public boolean needsSaving()
{
public boolean needsSaving() {
return fIsDirty;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#putValue(String, String)
*/
public void putValue( String name, String newValue )
{
public void putValue( String name, String newValue ) {
Object oldValue = fProperties.get( name );
if ( oldValue == null || !oldValue.equals( newValue ) )
{
if ( oldValue == null || !oldValue.equals( newValue ) ) {
fProperties.put( name, newValue );
setDirty( true );
}
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener)
*/
public void removePropertyChangeListener( IPropertyChangeListener listener )
{
public void removePropertyChangeListener( IPropertyChangeListener listener ) {
fListeners.remove( listener );
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, double)
*/
public void setDefault( String name, double value )
{
public void setDefault( String name, double value ) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, float)
*/
public void setDefault( String name, float value )
{
public void setDefault( String name, float value ) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, int)
*/
public void setDefault( String name, int value )
{
public void setDefault( String name, int value ) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, long)
*/
public void setDefault( String name, long value )
{
public void setDefault( String name, long value ) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, String)
*/
public void setDefault( String name, String defaultObject )
{
public void setDefault( String name, String defaultObject ) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setDefault(String, boolean)
*/
public void setDefault( String name, boolean value )
{
public void setDefault( String name, boolean value ) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(String)
*/
public void setToDefault( String name )
{
public void setToDefault( String name ) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, double)
*/
public void setValue( String name, double value )
{
public void setValue( String name, double value ) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, float)
*/
public void setValue( String name, float value )
{
public void setValue( String name, float value ) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, int)
*/
public void setValue( String name, int newValue )
{
public void setValue( String name, int newValue ) {
int oldValue = getInt( name );
if ( oldValue != newValue )
{
if ( oldValue != newValue ) {
fProperties.put( name, new Integer( newValue ) );
setDirty( true );
firePropertyChangeEvent( name, new Integer( oldValue ), new Integer( newValue ) );
}
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, long)
*/
public void setValue( String name, long value )
{
public void setValue( String name, long value ) {
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, String)
*/
public void setValue( String name, String newValue )
{
public void setValue( String name, String newValue ) {
Object oldValue = fProperties.get( name );
if ( oldValue == null || !oldValue.equals( newValue ) )
{
if ( oldValue == null || !oldValue.equals( newValue ) ) {
fProperties.put( name, newValue );
setDirty( true );
firePropertyChangeEvent( name, oldValue, newValue );
}
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferenceStore#setValue(String, boolean)
*/
public void setValue( String name, boolean newValue )
{
public void setValue( String name, boolean newValue ) {
boolean oldValue = getBoolean( name );
if ( oldValue != newValue )
{
if ( oldValue != newValue ) {
fProperties.put( name, new Boolean( newValue ) );
setDirty(true);
setDirty( true );
firePropertyChangeEvent( name, new Boolean( oldValue ), new Boolean( newValue ) );
}
}
protected void setDirty( boolean isDirty )
{
protected void setDirty( boolean isDirty ) {
fIsDirty = isDirty;
}
}
}

View file

@ -11,86 +11,87 @@
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.dialogs.PropertyDialogAction;
/**
*
* Presents a custom properties dialog to configure the attibutes of a C/C++ breakpoint.
*
* @since Sep 3, 2002
*/
public class CBreakpointPropertiesAction implements IObjectActionDelegate
{
public class CBreakpointPropertiesAction implements IObjectActionDelegate {
private IWorkbenchPart fPart;
private ICBreakpoint fBreakpoint;
/**
* Constructor for CBreakpointPropertiesAction.
*/
public CBreakpointPropertiesAction()
{
public CBreakpointPropertiesAction() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
*/
public void setActivePart( IAction action, IWorkbenchPart targetPart )
{
public void setActivePart( IAction action, IWorkbenchPart targetPart ) {
fPart = targetPart;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(IAction)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run( IAction action )
{
Dialog d = new CBreakpointPropertiesDialog( getActivePart().getSite().getShell(), getBreakpoint() );
d.open();
public void run( IAction action ) {
PropertyDialogAction propertyAction = new PropertyDialogAction( CDebugUIPlugin.getActiveWorkbenchShell(), new ISelectionProvider() {
public void addSelectionChangedListener( ISelectionChangedListener listener ) {
}
public ISelection getSelection() {
return new StructuredSelection( getBreakpoint() );
}
public void removeSelectionChangedListener( ISelectionChangedListener listener ) {
}
public void setSelection( ISelection selection ) {
}
} );
propertyAction.run();
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged( IAction action, ISelection selection )
{
if ( selection instanceof IStructuredSelection )
{
public void selectionChanged( IAction action, ISelection selection ) {
if ( selection instanceof IStructuredSelection ) {
IStructuredSelection ss = (IStructuredSelection)selection;
if ( ss.isEmpty() || ss.size() > 1 )
{
if ( ss.isEmpty() || ss.size() > 1 ) {
return;
}
Object element = ss.getFirstElement();
if ( element instanceof ICBreakpoint )
{
if ( element instanceof ICBreakpoint ) {
setBreakpoint( (ICBreakpoint)element );
}
}
}
protected IWorkbenchPart getActivePart()
{
protected IWorkbenchPart getActivePart() {
return fPart;
}
protected void setActivePart( IWorkbenchPart part )
{
fPart = part;
}
protected ICBreakpoint getBreakpoint()
{
protected ICBreakpoint getBreakpoint() {
return fBreakpoint;
}
protected void setBreakpoint( ICBreakpoint breakpoint )
{
protected void setBreakpoint( ICBreakpoint breakpoint ) {
fBreakpoint = breakpoint;
}
}
}

View file

@ -1,510 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.IPreferencePageContainer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.resource.JFaceColors;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
/**
*
*
* @since Aug 29, 2002
*/
public class CBreakpointPropertiesDialog extends Dialog
implements IPreferencePageContainer
{
/**
* Layout for the page container.
*
* @see CBreakpointPropertiesDialog#createPageContainer(Composite, int)
*/
private class PageLayout extends Layout
{
public void layout( Composite composite, boolean force )
{
Rectangle rect = composite.getClientArea();
Control[] children = composite.getChildren();
for ( int i = 0; i < children.length; i++ )
{
children[i].setSize( rect.width, rect.height );
}
}
public Point computeSize( Composite composite, int wHint, int hHint, boolean force )
{
if ( wHint != SWT.DEFAULT && hHint != SWT.DEFAULT )
return new Point( wHint, hHint );
int x = getMinimumPageSize().x;
int y = getMinimumPageSize().y;
Control[] children = composite.getChildren();
for ( int i = 0; i < children.length; i++ )
{
Point size = children[i].computeSize( SWT.DEFAULT, SWT.DEFAULT, force );
x = Math.max( x, size.x );
y = Math.max( y, size.y );
}
if ( wHint != SWT.DEFAULT )
x = wHint;
if ( hHint != SWT.DEFAULT )
y = hHint;
return new Point( x, y );
}
}
private Composite fTitleArea;
private Label fTitleImage;
private CLabel fMessageLabel;
private String fMessage;
private Color fNormalMsgAreaBackground;
private Image fErrorMsgImage;
private CBreakpointPreferencePage fPage;
private Button fOkButton;
/**
* Must declare our own images as the JFaceResource images will not be created unless
* a property/preference dialog has been shown
*/
protected static final String PREF_DLG_TITLE_IMG = "breakpoint_preference_dialog_title_image"; //$NON-NLS-1$
protected static final String PREF_DLG_IMG_TITLE_ERROR = "breakpoint_preference_dialog_title_error_image"; //$NON-NLS-1$
static
{
ImageRegistry reg = CDebugUIPlugin.getDefault().getImageRegistry();
reg.put( PREF_DLG_TITLE_IMG, ImageDescriptor.createFromFile( PreferenceDialog.class, "images/pref_dialog_title.gif" ) ); //$NON-NLS-1$
reg.put( PREF_DLG_IMG_TITLE_ERROR, ImageDescriptor.createFromFile( Dialog.class, "images/message_error.gif" ) ); //$NON-NLS-1$
}
/**
* The Composite in which a page is shown.
*/
private Composite fPageContainer;
/**
* The minimum page size; 200 by 200 by default.
*
* @see #setMinimumPageSize(Point)
*/
private Point fMinimumPageSize = new Point(200,200);
/**
* The breakpoint that this dialog is operating on
*/
private ICBreakpoint fBreakpoint;
/**
* The "fake" preference store used to interface between
* the breakpoint and the breakpoint preference page.
*/
private CBreakpointPreferenceStore fCBreakpointPreferenceStore;
/**
* Constructor for CBreakpointPropertiesDialog.
* @param parentShell
*/
public CBreakpointPropertiesDialog( Shell parentShell, ICBreakpoint breakpoint )
{
super( parentShell );
setBreakpoint( breakpoint );
fCBreakpointPreferenceStore= new CBreakpointPreferenceStore();
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePageContainer#getPreferenceStore()
*/
public IPreferenceStore getPreferenceStore()
{
return fCBreakpointPreferenceStore;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
*/
public void updateButtons()
{
if ( fOkButton != null )
{
fOkButton.setEnabled( fPage.isValid() );
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePageContainer#updateMessage()
*/
public void updateMessage()
{
String pageMessage = fPage.getMessage();
String pageErrorMessage = fPage.getErrorMessage();
// Adjust the font
if ( pageMessage == null && pageErrorMessage == null )
fMessageLabel.setFont( JFaceResources.getBannerFont() );
else
fMessageLabel.setFont( JFaceResources.getDialogFont() );
// Set the message and error message
if ( pageMessage == null )
{
setMessage( fPage.getTitle() );
}
else
{
setMessage( pageMessage );
}
setErrorMessage( pageErrorMessage );
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePageContainer#updateTitle()
*/
public void updateTitle()
{
setTitle( fPage.getTitle() );
}
/**
* Display the given error message. The currently displayed message
* is saved and will be redisplayed when the error message is set
* to <code>null</code>.
*
* @param errorMessage the errorMessage to display or <code>null</code>
*/
public void setErrorMessage( String errorMessage )
{
if ( errorMessage == null )
{
if ( fMessageLabel.getImage() != null )
{
// we were previously showing an error
fMessageLabel.setBackground( fNormalMsgAreaBackground );
fMessageLabel.setImage( null );
fTitleImage.setImage( CDebugUIPlugin.getDefault().getImageRegistry().get( PREF_DLG_TITLE_IMG ) );
fTitleArea.layout( true );
}
// show the message
setMessage( fMessage );
}
else
{
fMessageLabel.setText( errorMessage );
if ( fMessageLabel.getImage() == null )
{
// we were not previously showing an error
// lazy initialize the error background color and image
if ( fErrorMsgImage == null )
{
fErrorMsgImage = CDebugUIPlugin.getDefault().getImageRegistry().get( PREF_DLG_IMG_TITLE_ERROR );
}
// show the error
fNormalMsgAreaBackground = fMessageLabel.getBackground();
fMessageLabel.setBackground( JFaceColors.getErrorBackground( fMessageLabel.getDisplay() ) );
fMessageLabel.setImage( fErrorMsgImage );
fTitleImage.setImage( null );
fTitleArea.layout( true );
}
}
}
/**
* Set the message text. If the message line currently displays an error,
* the message is stored and will be shown after a call to clearErrorMessage
*/
public void setMessage( String newMessage )
{
fMessage = newMessage;
if ( fMessage == null )
{
fMessage = ""; //$NON-NLS-1$
}
if ( fMessageLabel.getImage() == null )
{
// we are not showing an error
fMessageLabel.setText( fMessage );
}
}
/**
* Sets the title for this dialog.
*
* @param title the title.
*/
public void setTitle( String title )
{
Shell shell = getShell();
if ( ( shell != null ) && !shell.isDisposed() )
{
shell.setText( title );
}
}
/**
* @see Dialog#okPressed()
*/
protected void okPressed()
{
final List changedProperties = new ArrayList( 5 );
getPreferenceStore().addPropertyChangeListener(
new IPropertyChangeListener()
{
/**
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
*/
public void propertyChange( PropertyChangeEvent event )
{
changedProperties.add( event.getProperty() );
}
} );
fPage.performOk();
setBreakpointProperties( changedProperties );
super.okPressed();
}
/**
* All of the properties that the user has changed via the dialog
* are written through to the breakpoint.
*/
protected void setBreakpointProperties( final List changedProperties )
{
IWorkspaceRunnable wr = new IWorkspaceRunnable()
{
public void run( IProgressMonitor monitor ) throws CoreException
{
ICBreakpoint breakpoint = getBreakpoint();
Iterator changed = changedProperties.iterator();
while ( changed.hasNext() )
{
String property = (String)changed.next();
if ( property.equals( CBreakpointPreferenceStore.IGNORE_COUNT ) )
{
breakpoint.setIgnoreCount( getPreferenceStore().getInt( CBreakpointPreferenceStore.IGNORE_COUNT ) );
}
else if ( property.equals( CBreakpointPreferenceStore.CONDITION ) )
{
breakpoint.setCondition( getPreferenceStore().getString( CBreakpointPreferenceStore.CONDITION ) );
}
}
}
};
try
{
ResourcesPlugin.getWorkspace().run( wr, null );
}
catch( CoreException ce )
{
CDebugUIPlugin.log( ce );
}
}
protected ICBreakpoint getBreakpoint()
{
return fBreakpoint;
}
protected void setBreakpoint( ICBreakpoint breakpoint )
{
fBreakpoint = breakpoint;
}
/**
* @see Dialog#createDialogArea(Composite)
*/
protected Control createDialogArea( Composite parent )
{
GridData gd;
Composite composite = (Composite) super.createDialogArea( parent );
((GridLayout)composite.getLayout()).numColumns = 1;
// Build the title area and separator line
Composite titleComposite = new Composite( composite, SWT.NONE );
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
titleComposite.setLayout( layout );
titleComposite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
createTitleArea( titleComposite );
Label titleBarSeparator = new Label( titleComposite, SWT.HORIZONTAL | SWT.SEPARATOR );
gd = new GridData( GridData.FILL_HORIZONTAL );
titleBarSeparator.setLayoutData( gd );
// Build the Page container
fPageContainer = createPageContainer( composite, 2 );
fPageContainer.setLayoutData( new GridData( GridData.FILL_BOTH ) );
fPageContainer.setFont( parent.getFont() );
fPage = new CBreakpointPreferencePage( getBreakpoint() );
fPage.setContainer( this );
fPage.createControl( fPageContainer );
// Build the separator line
Label separator = new Label( composite, SWT.HORIZONTAL | SWT.SEPARATOR );
gd = new GridData( GridData.FILL_HORIZONTAL );
gd.horizontalSpan = 2;
separator.setLayoutData( gd );
return composite;
}
/**
* Creates the dialog's title area.
*
* @param parent the SWT parent for the title area composite
* @return the created title area composite
*/
private Composite createTitleArea( Composite parent )
{
// Create the title area which will contain
// a title, message, and image.
fTitleArea = new Composite( parent, SWT.NONE );
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
layout.numColumns = 2;
// Get the colors for the title area
Display display = parent.getDisplay();
Color bg = JFaceColors.getBannerBackground( display );
Color fg = JFaceColors.getBannerForeground( display );
GridData layoutData = new GridData( GridData.FILL_BOTH );
fTitleArea.setLayout( layout );
fTitleArea.setLayoutData( layoutData );
fTitleArea.setBackground( bg );
// Message label
fMessageLabel = new CLabel( fTitleArea, SWT.LEFT );
fMessageLabel.setBackground( bg );
fMessageLabel.setForeground( fg );
fMessageLabel.setText( " " ); //$NON-NLS-1$
fMessageLabel.setFont( JFaceResources.getBannerFont() );
final IPropertyChangeListener fontListener =
new IPropertyChangeListener()
{
public void propertyChange( PropertyChangeEvent event )
{
if ( JFaceResources.BANNER_FONT.equals( event.getProperty() ) ||
JFaceResources.DIALOG_FONT.equals( event.getProperty() ) )
{
updateMessage();
}
}
};
fMessageLabel.addDisposeListener(
new DisposeListener()
{
public void widgetDisposed( DisposeEvent event )
{
JFaceResources.getFontRegistry().removeListener( fontListener );
}
} );
JFaceResources.getFontRegistry().addListener( fontListener );
GridData gd = new GridData( GridData.FILL_BOTH );
fMessageLabel.setLayoutData( gd );
// Title image
fTitleImage = new Label( fTitleArea, SWT.LEFT );
fTitleImage.setBackground( bg );
fTitleImage.setImage( CDebugUIPlugin.getDefault().getImageRegistry().get( PREF_DLG_TITLE_IMG ) );
gd = new GridData();
gd.horizontalAlignment = GridData.END;
fTitleImage.setLayoutData( gd );
return fTitleArea;
}
/**
* Creates the inner page container.
*/
private Composite createPageContainer( Composite parent, int numColumns )
{
Composite result = new Composite( parent, SWT.NULL );
result.setLayout( new PageLayout() );
return result;
}
/**
* Sets the minimum page size.
*
* @param size the page size encoded as
* <code>new Point(width,height)</code>
* @see #setMinimumPageSize(int,int)
*/
public void setMinimumPageSize( Point size )
{
fMinimumPageSize.x = size.x;
fMinimumPageSize.y = size.y;
}
/**
* @see Dialog#createButtonsForButtonBar(Composite)
*/
protected void createButtonsForButtonBar( Composite parent )
{
fOkButton = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true );
createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
}
protected Point getMinimumPageSize()
{
return fMinimumPageSize;
}
}

View file

@ -13,9 +13,13 @@ package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.dialogs.PropertyDialogAction;
import org.eclipse.ui.help.WorkbenchHelp;
/**
@ -40,8 +44,22 @@ public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAct
*/
public void run() {
if ( getBreakpoint() != null ) {
Dialog d = new CBreakpointPropertiesDialog( getTargetPart().getSite().getShell(), (ICBreakpoint)getBreakpoint() );
d.open();
PropertyDialogAction action = new PropertyDialogAction( getTargetPart().getSite().getShell(), new ISelectionProvider() {
public void addSelectionChangedListener( ISelectionChangedListener listener ) {
}
public ISelection getSelection() {
return new StructuredSelection( getBreakpoint() );
}
public void removeSelectionChangedListener( ISelectionChangedListener listener ) {
}
public void setSelection( ISelection selection ) {
}
} );
action.run();
}
}

View file

@ -1,13 +1,9 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
/***************************************************************************************************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others. All rights reserved. This program and the accompanying materials are made available under the terms
* of the Common Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
* Contributors: QNX Software Systems - Initial API and implementation
**************************************************************************************************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.jface.action.IAction;
@ -15,19 +11,12 @@ import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
import org.eclipse.ui.texteditor.ITextEditor;
/**
*
* Enter type comment.
*
* @since Aug 29, 2002
*/
public class CBreakpointPropertiesRulerActionDelegate extends AbstractRulerActionDelegate
{
public class CBreakpointPropertiesRulerActionDelegate extends AbstractRulerActionDelegate {
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
* @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(org.eclipse.ui.texteditor.ITextEditor, org.eclipse.jface.text.source.IVerticalRulerInfo)
*/
protected IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo )
{
protected IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo ) {
return new CBreakpointPropertiesRulerAction( editor, rulerInfo );
}
}
}

View file

@ -10,37 +10,48 @@
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
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.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchPropertyPage;
/**
* The preference page used to present the properties of a breakpoint as preferences. A CBreakpointPreferenceStore is used to interface between this page and
* the breakpoint.
*/
public class CBreakpointPreferencePage extends FieldEditorPreferencePage {
public class CBreakpointPropertyPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage {
class BreakpointIntegerFieldEditor extends IntegerFieldEditor {
public BreakpointIntegerFieldEditor( String name, String labelText, Composite parent ) {
super( name, labelText, parent );
setErrorMessage( ActionMessages.getString( "CBreakpointPreferencePage.0" ) ); //$NON-NLS-1$
setErrorMessage( ActionMessages.getString( "CBreakpointPropertyPage.0" ) ); //$NON-NLS-1$
}
/**
@ -203,23 +214,31 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage {
}
}
private BooleanFieldEditor fEnabled;
private BreakpointStringFieldEditor fCondition;
private Text fIgnoreCountTextControl;
private BreakpointIntegerFieldEditor fIgnoreCount;
private ICBreakpoint fBreakpoint;
private IAdaptable fElement;
/**
* Constructor for CBreakpointPreferencePage.
* The "fake" preference store used to interface between
* the breakpoint and the breakpoint preference page.
*/
private CBreakpointPreferenceStore fCBreakpointPreferenceStore;
/**
* Constructor for CBreakpointPropertyPage.
*
* @param breakpoint
*/
public CBreakpointPreferencePage( ICBreakpoint breakpoint ) {
public CBreakpointPropertyPage() {
super( GRID );
setBreakpoint( breakpoint );
noDefaultAndApplyButton();
fCBreakpointPreferenceStore = new CBreakpointPreferenceStore();
}
/*
@ -230,6 +249,7 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage {
protected void createFieldEditors() {
ICBreakpoint breakpoint = getBreakpoint();
createTypeSpecificLabelFieldEditors( breakpoint );
createEnabledField( getFieldEditorParent() );
IPreferenceStore store = getPreferenceStore();
try {
String condition = breakpoint.getCondition();
@ -256,7 +276,8 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage {
private void createTypeSpecificLabelFieldEditors( ICBreakpoint breakpoint ) {
if ( breakpoint instanceof ICFunctionBreakpoint ) {
ICFunctionBreakpoint fbrkpt = (ICFunctionBreakpoint)breakpoint;
String function = ActionMessages.getString( "CBreakpointPreferencePage.1" ); //$NON-NLS-1$
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPropertyPage.18" ), ActionMessages.getString( "CBreakpointPropertyPage.3" ) ) ); //$NON-NLS-1$//$NON-NLS-2$
String function = ActionMessages.getString( "CBreakpointPropertyPage.1" ); //$NON-NLS-1$
try {
function = fbrkpt.getFunction();
}
@ -265,13 +286,13 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage {
catch( NumberFormatException e ) {
}
if ( function != null ) {
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPreferencePage.2" ), function ) ); //$NON-NLS-1$
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPropertyPage.2" ), function ) ); //$NON-NLS-1$
}
setTitle( ActionMessages.getString( "CBreakpointPreferencePage.3" ) ); //$NON-NLS-1$
}
else if ( breakpoint instanceof ICAddressBreakpoint ) {
ICAddressBreakpoint abrkpt = (ICAddressBreakpoint)breakpoint;
String address = ActionMessages.getString( "CBreakpointPreferencePage.4" ); //$NON-NLS-1$
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPropertyPage.18" ), ActionMessages.getString( "CBreakpointPropertyPage.6" ) ) ); //$NON-NLS-1$//$NON-NLS-2$
String address = ActionMessages.getString( "CBreakpointPropertyPage.4" ); //$NON-NLS-1$
try {
address = CDebugUtils.toHexAddressString( Long.parseLong( abrkpt.getAddress() ) );
}
@ -280,16 +301,15 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage {
catch( NumberFormatException e ) {
}
if ( address != null ) {
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPreferencePage.5" ), address ) ); //$NON-NLS-1$
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPropertyPage.5" ), address ) ); //$NON-NLS-1$
}
setTitle( ActionMessages.getString( "CBreakpointPreferencePage.6" ) ); //$NON-NLS-1$
}
else if ( breakpoint instanceof ILineBreakpoint ) {
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPropertyPage.18" ), ActionMessages.getString( "CBreakpointPropertyPage.8" ) ) ); //$NON-NLS-1$//$NON-NLS-2$
String fileName = breakpoint.getMarker().getResource().getLocation().toOSString();
if ( fileName != null ) {
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPreferencePage.7" ), fileName ) ); //$NON-NLS-1$
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPropertyPage.7" ), fileName ) ); //$NON-NLS-1$
}
setTitle( ActionMessages.getString( "CBreakpointPreferencePage.8" ) ); //$NON-NLS-1$
ILineBreakpoint lBreakpoint = (ILineBreakpoint)breakpoint;
StringBuffer lineNumber = new StringBuffer( 4 );
try {
@ -302,43 +322,48 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage {
CDebugUIPlugin.log( ce );
}
if ( lineNumber.length() > 0 ) {
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPreferencePage.9" ), lineNumber.toString() ) ); //$NON-NLS-1$
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPropertyPage.9" ), lineNumber.toString() ) ); //$NON-NLS-1$
}
}
else if ( breakpoint instanceof ICWatchpoint ) {
String projectName = breakpoint.getMarker().getResource().getLocation().toOSString();
if ( projectName != null ) {
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPreferencePage.10" ), projectName ) ); //$NON-NLS-1$
}
ICWatchpoint watchpoint = (ICWatchpoint)breakpoint;
String title = ""; //$NON-NLS-1$
String type = ""; //$NON-NLS-1$
String expression = ""; //$NON-NLS-1$
try {
if ( watchpoint.isReadType() && !watchpoint.isWriteType() )
title = ActionMessages.getString( "CBreakpointPreferencePage.11" ); //$NON-NLS-1$
type = ActionMessages.getString( "CBreakpointPropertyPage.11" ); //$NON-NLS-1$
else if ( !watchpoint.isReadType() && watchpoint.isWriteType() )
title = ActionMessages.getString( "CBreakpointPreferencePage.12" ); //$NON-NLS-1$
type = ActionMessages.getString( "CBreakpointPropertyPage.12" ); //$NON-NLS-1$
else
title = ActionMessages.getString( "CBreakpointPreferencePage.13" ); //$NON-NLS-1$
type = ActionMessages.getString( "CBreakpointPropertyPage.13" ); //$NON-NLS-1$
expression = watchpoint.getExpression();
}
catch( CoreException ce ) {
CDebugUIPlugin.log( ce );
}
setTitle( title );
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPreferencePage.14" ), expression ) ); //$NON-NLS-1$
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPropertyPage.18" ), type ) ); //$NON-NLS-1$
String projectName = breakpoint.getMarker().getResource().getLocation().toOSString();
if ( projectName != null ) {
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPropertyPage.10" ), projectName ) ); //$NON-NLS-1$
}
addField( createLabelEditor( getFieldEditorParent(), ActionMessages.getString( "CBreakpointPropertyPage.14" ), expression ) ); //$NON-NLS-1$
}
}
protected void createEnabledField( Composite parent ) {
fEnabled = new BooleanFieldEditor( CBreakpointPreferenceStore.ENABLED, ActionMessages.getString( "CBreakpointPropertyPage.19" ), parent ); //$NON-NLS-1$
addField( fEnabled );
}
protected void createConditionEditor( Composite parent ) {
fCondition = new BreakpointStringFieldEditor( CBreakpointPreferenceStore.CONDITION, ActionMessages.getString( "CBreakpointPreferencePage.15" ), parent ); //$NON-NLS-1$
fCondition = new BreakpointStringFieldEditor( CBreakpointPreferenceStore.CONDITION, ActionMessages.getString( "CBreakpointPropertyPage.15" ), parent ); //$NON-NLS-1$
fCondition.setEmptyStringAllowed( true );
fCondition.setErrorMessage( ActionMessages.getString( "CBreakpointPreferencePage.16" ) ); //$NON-NLS-1$
fCondition.setErrorMessage( ActionMessages.getString( "CBreakpointPropertyPage.16" ) ); //$NON-NLS-1$
addField( fCondition );
}
protected void createIgnoreCountEditor( Composite parent ) {
fIgnoreCount = new BreakpointIntegerFieldEditor( CBreakpointPreferenceStore.IGNORE_COUNT, ActionMessages.getString( "CBreakpointPreferencePage.17" ), parent ); //$NON-NLS-1$
fIgnoreCount = new BreakpointIntegerFieldEditor( CBreakpointPreferenceStore.IGNORE_COUNT, ActionMessages.getString( "CBreakpointPropertyPage.17" ), parent ); //$NON-NLS-1$
fIgnoreCount.setValidRange( 0, Integer.MAX_VALUE );
fIgnoreCountTextControl = fIgnoreCount.getTextControl( parent );
try {
@ -355,10 +380,69 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage {
}
protected ICBreakpoint getBreakpoint() {
return fBreakpoint;
IAdaptable element = getElement();
return ( element instanceof ICBreakpoint ) ? (ICBreakpoint)element : null;
}
protected void setBreakpoint( ICBreakpoint breakpoint ) {
fBreakpoint = breakpoint;
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
*/
public IAdaptable getElement() {
return fElement;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
*/
public void setElement( IAdaptable element ) {
fElement = element;
}
public IPreferenceStore getPreferenceStore() {
return fCBreakpointPreferenceStore;
}
public boolean performOk() {
final List changedProperties = new ArrayList( 5 );
getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener() {
/**
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
*/
public void propertyChange( PropertyChangeEvent event ) {
changedProperties.add( event.getProperty() );
}
} );
boolean result = super.performOk();
setBreakpointProperties( changedProperties );
return result;
}
protected void setBreakpointProperties( final List changedProperties ) {
IWorkspaceRunnable wr = new IWorkspaceRunnable() {
public void run( IProgressMonitor monitor ) throws CoreException {
ICBreakpoint breakpoint = getBreakpoint();
Iterator changed = changedProperties.iterator();
while( changed.hasNext() ) {
String property = (String)changed.next();
if ( property.equals( CBreakpointPreferenceStore.ENABLED ) ) {
breakpoint.setEnabled( getPreferenceStore().getBoolean( CBreakpointPreferenceStore.ENABLED ) );
}
else if ( property.equals( CBreakpointPreferenceStore.IGNORE_COUNT ) ) {
breakpoint.setIgnoreCount( getPreferenceStore().getInt( CBreakpointPreferenceStore.IGNORE_COUNT ) );
}
else if ( property.equals( CBreakpointPreferenceStore.CONDITION ) ) {
breakpoint.setCondition( getPreferenceStore().getString( CBreakpointPreferenceStore.CONDITION ) );
}
}
}
};
try {
ResourcesPlugin.getWorkspace().run( wr, null );
}
catch( CoreException ce ) {
CDebugUIPlugin.log( ce );
}
}
}