mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 560275 - Move watchpoint type check into labelprovider adapter
This makes it possible for a user to subclass CBreakpointPropertyPage and use their own adapter to decide the breakpoint label for watchpoints. Change-Id: I086179c6b5561b77410fd2a6f7d77bb6084d94d4 Signed-off-by: Anton Backstrom <anton.backstrom@gaisler.com>
This commit is contained in:
parent
5a6b9b4bf4
commit
a41ea21383
2 changed files with 18 additions and 17 deletions
|
@ -184,8 +184,8 @@ class CBreakpointContextWorkbenchAdapter implements IWorkbenchAdapter {
|
|||
@Override
|
||||
public String getLabel(Object o) {
|
||||
if (o instanceof ICBreakpointContext) {
|
||||
ICBreakpoint bp = ((ICBreakpointContext) o).getBreakpoint();
|
||||
return getBreakpointMainLabel(bp);
|
||||
ICBreakpointContext context = (ICBreakpointContext) o;
|
||||
return getBreakpointMainLabel(context.getBreakpoint(), context);
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ class CBreakpointContextWorkbenchAdapter implements IWorkbenchAdapter {
|
|||
return null;
|
||||
}
|
||||
|
||||
private String getBreakpointMainLabel(ICBreakpoint breakpoint) {
|
||||
private String getBreakpointMainLabel(ICBreakpoint breakpoint, ICBreakpointContext o) {
|
||||
if (breakpoint instanceof ICFunctionBreakpoint) {
|
||||
if (breakpoint instanceof ICTracepoint) {
|
||||
return BreakpointsMessages.getString("TracepointPropertyPage.tracepointType_function_label"); //$NON-NLS-1$
|
||||
|
@ -233,6 +233,21 @@ class CBreakpointContextWorkbenchAdapter implements IWorkbenchAdapter {
|
|||
} else if (breakpoint instanceof ICEventBreakpoint) {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_event_label"); //$NON-NLS-1$
|
||||
} else if (breakpoint instanceof ICWatchpoint) {
|
||||
if (breakpoint.getMarker() != null) {
|
||||
// For an existing breakpoint, calculate watchpoint label based
|
||||
// on read/write type.
|
||||
boolean isReadType = o.getPreferenceStore().getBoolean(ICWatchpoint.READ);
|
||||
boolean isWriteType = o.getPreferenceStore().getBoolean(ICWatchpoint.WRITE);
|
||||
if (isReadType && !isWriteType) {
|
||||
return BreakpointsMessages
|
||||
.getString("CBreakpointPropertyPage.breakpointType_watchpoint_read_label"); //$NON-NLS-1$
|
||||
} else if (!isReadType && isWriteType) {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$
|
||||
} else {
|
||||
return BreakpointsMessages
|
||||
.getString("CBreakpointPropertyPage.breakpointType_watchpoint_access_label"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$
|
||||
}
|
||||
// default main label is the label of marker type for the breakpoint
|
||||
|
|
|
@ -650,20 +650,6 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
|
|||
}
|
||||
|
||||
private String getBreakpointMainLabel(ICBreakpoint breakpoint) {
|
||||
if (breakpoint instanceof ICWatchpoint && breakpoint.getMarker() != null) {
|
||||
// For an existing breakpoint, calculate watchpoint label based
|
||||
// on read/write type.
|
||||
boolean isReadType = getPreferenceStore().getBoolean(ICWatchpoint.READ);
|
||||
boolean isWriteType = getPreferenceStore().getBoolean(ICWatchpoint.WRITE);
|
||||
if (isReadType && !isWriteType) {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_read_label"); //$NON-NLS-1$
|
||||
} else if (!isReadType && isWriteType) {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_label"); //$NON-NLS-1$
|
||||
} else {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_watchpoint_access_label"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
IWorkbenchAdapter labelProvider = getElement().getAdapter(IWorkbenchAdapter.class);
|
||||
if (labelProvider != null) {
|
||||
return labelProvider.getLabel(getElement());
|
||||
|
|
Loading…
Add table
Reference in a new issue