CBreakpointPropertyPage.breakpointType_line_label=C/C++ Line Breakpoint
CBreakpointPropertyPage.lineNumber_errorMessage=Enter a line number greater than 0
CBreakpointPropertyPage.lineNumber_label=Line number:
+CBreakpointPropertyPage.breakpoint_already_exists_errorMessage=Breakpoint exists at this location
CBreakpointPropertyPage.breakpointType_event_label=C/C++ Event Breakpoint
CBreakpointPropertyPage.project_label=Project:
CBreakpointPropertyPage.breakpointType_watchpoint_label=C/C++ Watchpoint
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugModelProvider;
import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
private Text fIgnoreCountTextControl;
+ private BreakpointFileNameFieldEditor fFileEditor;
+ private BreakpointIntegerFieldEditor fLineEditor;
private BreakpointIntegerFieldEditor fIgnoreCount;
-
+
private IAdaptable fElement;
+ /**
+ * Indicates if the page currently aims to create
+ * a breakpoint that already exits.
+ */
+ private boolean fDuplicateBreakpoint;
+
/**
* The preference store used to interface between the breakpoint and the
* breakpoint preference page. This preference store is initialized only
// fCBreakpointPreferenceStore = new CBreakpointPreferenceStore();
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
- */
@Override
protected void createFieldEditors() {
ICBreakpoint breakpoint = getBreakpoint();
boolean isFilenameEditable = fileName != null && fileName.isEmpty();
if (isNewBreakpoint && isFilenameEditable) {
- BreakpointFileNameFieldEditor fileNameEditor = new BreakpointFileNameFieldEditor(
+ fFileEditor = new BreakpointFileNameFieldEditor(
ICLineBreakpoint.SOURCE_HANDLE, title, parent);
- fileNameEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.fileName_errorMessage")); //$NON-NLS-1$
- fileNameEditor.setEmptyStringAllowed(false);
- addField(fileNameEditor);
+ fFileEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.fileName_errorMessage")); //$NON-NLS-1$
+ fFileEditor.setEmptyStringAllowed(false);
+ addField(fFileEditor);
} else {
if (fileName != null) {
addField(createLabelEditor(parent, title, fileName));
protected void createLineNumberEditor( Composite parent ) {
String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.lineNumber_label" ); //$NON-NLS-1$
- BreakpointIntegerFieldEditor labelFieldEditor =new BreakpointIntegerFieldEditor( IMarker.LINE_NUMBER ,title, parent);
- labelFieldEditor.setValidRange( 1, Integer.MAX_VALUE );
- labelFieldEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.lineNumber_errorMessage")); //$NON-NLS-1$
- addField( labelFieldEditor );
+ fLineEditor = new BreakpointIntegerFieldEditor(IMarker.LINE_NUMBER ,title, parent);
+ fLineEditor.setValidRange(1, Integer.MAX_VALUE);
+ fLineEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.lineNumber_errorMessage")); //$NON-NLS-1$
+ addField(fLineEditor);
}
protected void createWatchExpressionEditor( Composite parent ) {
return new LabelFieldEditor( parent, title, value );
}
+ @Override
+ public boolean isValid() {
+ // Don't allow to create a duplicate breakpoint
+ return super.isValid() && !fDuplicateBreakpoint;
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ super.propertyChange(event);
+
+ ICBreakpoint currentBp = getBreakpoint();
+ if (!(currentBp instanceof ICFunctionBreakpoint) &&
+ !(currentBp instanceof ICAddressBreakpoint)) {
+ // Check for duplication of line breakpoints
+ if (event.getProperty().equals(FieldEditor.VALUE)) {
+ if (super.isValid()) {
+ // For every change, if all the fields are valid
+ // we then check if we are dealing with a duplicate
+ // breakpoint.
+ boolean oldValue = fDuplicateBreakpoint;
+ fDuplicateBreakpoint = isDuplicateBreakpoint();
+ if (oldValue != fDuplicateBreakpoint) {
+ if (fDuplicateBreakpoint) {
+ setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.breakpoint_already_exists_errorMessage")); //$NON-NLS-1$
+ } else {
+ setErrorMessage(null);
+ }
+ // update container state
+ if (getContainer() != null) {
+ getContainer().updateButtons();
+ }
+ // update page state
+ updateApplyButton();
+ }
+ }
+ }
+ }
+ }
+
+ private boolean isDuplicateBreakpoint() {
+ String source = null;
+ if (fFileEditor != null) {
+ source = fFileEditor.getStringValue();
+ } else {
+ // If the source file is not editable, we should fetch
+ // it from the preference store
+ source = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE);
+ }
+
+ int line = fLineEditor.getIntValue();
+
+ // Look for any breakpoint that has the same source file and line number as what
+ // is currently being inputed. Careful not to compare with the current breakpoint
+ // in the case of modifying the breakpoint properties of an existing breakpoint; in
+ // that case we of course have this particular bp at this file and line.
+ ICBreakpoint currentBp = getBreakpoint();
+ IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();
+ for (IBreakpoint bp : breakpoints) {
+ if (!bp.equals(currentBp) && bp instanceof ICBreakpoint) {
+ IMarker marker = bp.getMarker();
+ if (marker != null) {
+ String markerFile = marker.getAttribute(ICBreakpoint.SOURCE_HANDLE, ""); //$NON-NLS-1$
+ int markerLine = marker.getAttribute(IMarker.LINE_NUMBER, -1);
+ if (source.equals(markerFile) && line == markerLine) {
+ // Woops, we already have another breakpoint at this file:line
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
protected ICBreakpoint getBreakpoint() {
IAdaptable element = getElement();
if (element instanceof ICBreakpoint) {
/*******************************************************************************
- * Copyright (c) 2014 Ericsson and others.
+ * Copyright (c) 2014, 2015 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
import org.eclipse.cdt.debug.core.model.ICDynamicPrintf;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.internal.ui.breakpoints.BreakpointsMessages;
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext;
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointPreferenceStore;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugModelProvider;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Composite;
private DynamicPrintfStringFieldEditor fCondition;
private Text fIgnoreCountTextControl;
+ private DynamicPrintfIntegerFieldEditor fLineEditor;
private DynamicPrintfIntegerFieldEditor fIgnoreCount;
+ /**
+ * Indicates if the page currently aims to create
+ * a breakpoint that already exits.
+ */
+ private boolean fDuplicateBreakpoint;
+
+
private DynamicPrintfStringFieldEditor fPrintString;
private IAdaptable fElement;
noDefaultAndApplyButton();
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
- */
@Override
protected void createFieldEditors() {
ICDynamicPrintf dprintf = getDprintf();
}
protected void createLineNumberEditor(Composite parent) {
String title = Messages.PropertyPage_LineNumber;
- DynamicPrintfIntegerFieldEditor labelFieldEditor = new DynamicPrintfIntegerFieldEditor(IMarker.LINE_NUMBER, title, parent);
- labelFieldEditor.setValidRange(1, Integer.MAX_VALUE);
- addField(labelFieldEditor);
+ fLineEditor = new DynamicPrintfIntegerFieldEditor(IMarker.LINE_NUMBER, title, parent);
+ fLineEditor.setValidRange(1, Integer.MAX_VALUE);
+ fLineEditor.setErrorMessage(Messages.PropertyPage_lineNumber_errorMessage);
+ addField(fLineEditor);
}
protected void createEnabledField(Composite parent) {
addField(fPrintString);
}
+ @Override
+ public boolean isValid() {
+ // Don't allow to create a duplicate breakpoint
+ return super.isValid() && !fDuplicateBreakpoint;
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ super.propertyChange(event);
+
+ ICBreakpoint currentBp = getDprintf();
+ if (!(currentBp instanceof ICFunctionBreakpoint) &&
+ !(currentBp instanceof ICAddressBreakpoint)) {
+ // Check for duplication of line dprintf
+ if (event.getProperty().equals(FieldEditor.VALUE)) {
+ if (super.isValid()) {
+ // For every change, if all the fields are valid
+ // we then check if we are dealing with a duplicate
+ // breakpoint.
+ boolean oldValue = fDuplicateBreakpoint;
+ fDuplicateBreakpoint = isDuplicateBreakpoint();
+ if (oldValue != fDuplicateBreakpoint) {
+ if (fDuplicateBreakpoint) {
+ setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.breakpoint_already_exists_errorMessage")); //$NON-NLS-1$
+ } else {
+ setErrorMessage(null);
+ }
+ // update container state
+ if (getContainer() != null) {
+ getContainer().updateButtons();
+ }
+ // update page state
+ updateApplyButton();
+ }
+ }
+ }
+ }
+ }
+
+ private boolean isDuplicateBreakpoint() {
+ String source = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE);
+ int line = fLineEditor.getIntValue();
+
+ // Look for any breakpoint (base bp class) that has the same source file and line number as what
+ // is currently being inputed. Careful not to compare with the current dprintf
+ // in the case of modifying the properties of an existing dprintf; in
+ // that case we of course have this particular dprintf at this file and line.
+ ICBreakpoint currentBp = getDprintf();
+ IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();
+ for (IBreakpoint bp : breakpoints) {
+ if (!bp.equals(currentBp) && bp instanceof ICBreakpoint) {
+ IMarker marker = bp.getMarker();
+ if (marker != null) {
+ String markerFile = marker.getAttribute(ICBreakpoint.SOURCE_HANDLE, ""); //$NON-NLS-1$
+ int markerLine = marker.getAttribute(IMarker.LINE_NUMBER, -1);
+ if (source.equals(markerFile) && line == markerLine) {
+ // Woops, we already have another breakpoint at this file:line
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
protected FieldEditor createLabelEditor(Composite parent, String title, String value) {
return new LabelFieldEditor(parent, title, value);
}
/*******************************************************************************
- * Copyright (c) 2009, 2014 Ericsson and others.
+ * Copyright (c) 2009, 2015 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICTracepoint;
+import org.eclipse.cdt.debug.internal.ui.breakpoints.BreakpointsMessages;
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext;
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointPreferenceStore;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugModelProvider;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Composite;
private TracepointStringFieldEditor fCondition;
private Text fIgnoreCountTextControl;
+
+ private TracepointIntegerFieldEditor fLineEditor;
private TracepointIntegerFieldEditor fIgnoreCount;
+ /**
+ * Indicates if the page currently aims to create
+ * a breakpoint that already exits.
+ */
+ private boolean fDuplicateBreakpoint;
+
private Text fPassCountTextControl;
private TracepointIntegerFieldEditor fPassCount;
noDefaultAndApplyButton();
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
- */
@Override
protected void createFieldEditors() {
ICTracepoint tracepoint = getTracepoint();
}
protected void createLineNumberEditor(Composite parent) {
String title = Messages.PropertyPage_LineNumber;
- TracepointIntegerFieldEditor labelFieldEditor = new TracepointIntegerFieldEditor(IMarker.LINE_NUMBER, title, parent);
- labelFieldEditor.setValidRange(1, Integer.MAX_VALUE);
- addField(labelFieldEditor);
+ fLineEditor = new TracepointIntegerFieldEditor(IMarker.LINE_NUMBER, title, parent);
+ fLineEditor.setValidRange(1, Integer.MAX_VALUE);
+ fLineEditor.setErrorMessage(Messages.PropertyPage_lineNumber_errorMessage);
+ addField(fLineEditor);
}
protected void createEnabledField(Composite parent) {
return new LabelFieldEditor(parent, title, value);
}
+ @Override
+ public boolean isValid() {
+ // Don't allow to create a duplicate breakpoint
+ return super.isValid() && !fDuplicateBreakpoint;
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ super.propertyChange(event);
+
+ ICBreakpoint currentBp = getTracepoint();
+ if (!(currentBp instanceof ICFunctionBreakpoint) &&
+ !(currentBp instanceof ICAddressBreakpoint)) {
+ // Check for duplication of line tracepoints
+
+ if (event.getProperty().equals(FieldEditor.VALUE)) {
+ if (super.isValid()) {
+ // For every change, if all the fields are valid
+ // we then check if we are dealing with a duplicate
+ // breakpoint.
+ boolean oldValue = fDuplicateBreakpoint;
+ fDuplicateBreakpoint = isDuplicateBreakpoint();
+ if (oldValue != fDuplicateBreakpoint) {
+ if (fDuplicateBreakpoint) {
+ setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.breakpoint_already_exists_errorMessage")); //$NON-NLS-1$
+ } else {
+ setErrorMessage(null);
+ }
+ // update container state
+ if (getContainer() != null) {
+ getContainer().updateButtons();
+ }
+ // update page state
+ updateApplyButton();
+ }
+ }
+ }
+ }
+ }
+
+ private boolean isDuplicateBreakpoint() {
+ String source = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE);
+ int line = fLineEditor.getIntValue();
+
+ // Look for any breakpoint (base class) that has the same source file and line number as what
+ // is currently being inputed. Careful not to compare with the current tracepoint
+ // in the case of modifying the properties of an existing tracepoint; in
+ // that case we of course have this particular tracepoint at this file and line.
+ ICBreakpoint currentBp = getTracepoint();
+ IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();
+ for (IBreakpoint bp : breakpoints) {
+ if (!bp.equals(currentBp) && bp instanceof ICBreakpoint) {
+ IMarker marker = bp.getMarker();
+ if (marker != null) {
+ String markerFile = marker.getAttribute(ICBreakpoint.SOURCE_HANDLE, ""); //$NON-NLS-1$
+ int markerLine = marker.getAttribute(IMarker.LINE_NUMBER, -1);
+ if (source.equals(markerFile) && line == markerLine) {
+ // Woops, we already have another breakpoint at this file:line
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
protected ICTracepoint getTracepoint() {
IAdaptable element = getElement();
if (element instanceof ICTracepoint) {
/*******************************************************************************
- * Copyright (c) 2009, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2015 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
public static String PropertyPage_function_value_errorMessage;
public static String PropertyPage_Class;
public static String PropertyPage_Enabled;
+ public static String PropertyPage_lineNumber_errorMessage;
public static String DynamicPrintfPropertyPage_PrintString;
public static String GdbThreadFilterEditor_Thread;
###############################################################################
-# Copyright (c) 2009, 2014 Wind River Systems and others.
+# Copyright (c) 2009, 2015 Wind River Systems and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
PropertyPage_Class=Class:
PropertyPage_Enabled=Enabled
PropertyPage_function_value_errorMessage=Enter a function expression:
+PropertyPage_lineNumber_errorMessage=Enter a line number greater than 0
DynamicPrintfPropertyPage_PrintString=&printf(
ToggleDynamicPrintfTargetFactory_description=Standard C/C++ Dynamic Printf type.