mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 12:45:41 +02:00
Bug 374512 - breakpointContribution does not support custom
field editors Also addresses: Bug 374514 - breakpointContribution always add Widgets on top of common properties page Bug 374508 - breakpointContribution does not support restrictions
This commit is contained in:
parent
dce877458e
commit
6d107cd42e
13 changed files with 411 additions and 94 deletions
|
@ -35,8 +35,8 @@ public interface ICBreakpoint extends IBreakpoint {
|
|||
/**
|
||||
* This debug model identifier can be returned by a debug implementation
|
||||
* to indicate that a given debugger integration is using C Breakpoints.
|
||||
* This model ID will allow breakpoint actions to configure their default
|
||||
* selection.
|
||||
* This model ID will allow toggle breakpoint actions to configure their
|
||||
* default selection.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
|
|
|
@ -9,4 +9,11 @@
|
|||
</message_arguments>
|
||||
</filter>
|
||||
</resource>
|
||||
<resource path="src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java" type="org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution">
|
||||
<filter comment="@noimplement and @noextend attributes were previously implied in interface declaration." id="403853384">
|
||||
<message_arguments>
|
||||
<message_argument value="org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution"/>
|
||||
</message_arguments>
|
||||
</filter>
|
||||
</resource>
|
||||
</component>
|
||||
|
|
|
@ -2,18 +2,26 @@
|
|||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.cdt.debug.ui" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.schema plugin="org.eclipse.cdt.debug.ui" id="breakpointContribution" name="Breakpoint UI Contribution"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
This extension point provides a mechanism for contributing UI to view and edit breakpoint attributes.
|
||||
This extension point provides a mechanism for contributing controls for viewing and editing breakpoint attributes.
|
||||
The UI controls are added to the "Common" page of the breakpoint properties dialog. If a debug model ID is specified, the
|
||||
contribution is shown only when a debugger with corresponding model ID is currently active.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.element />
|
||||
</appInfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<element ref="breakpointLabels"/>
|
||||
<element ref="breakpointLabels" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<element ref="breakpointEditors" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
|
@ -34,15 +42,20 @@
|
|||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="breakpointLabels">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A breakpoint label is appended to the top section the breakpoint properties common page.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<element ref="attribute"/>
|
||||
|
@ -50,28 +63,65 @@
|
|||
<attribute name="markerType" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
marker type for which attribute labels are applied
|
||||
Breakpoint's marker type for which the given attribute labels are applied.
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute kind="identifier"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="debugModelId" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
debug model Id for this extension is valid
|
||||
(debugModelId is a property of cbreakpoint)
|
||||
Debug model Id of the active debug context for which this extension is valid. If not specified or if the model ID equals the CDT breakpoint's model (org.eclipse.cdt.debug.core), the option is always shown.
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute kind="identifier"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="breakpointEditors">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A breakpoint editor is appended to the bottom section the breakpoint properties common page.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<element ref="attribute"/>
|
||||
</sequence>
|
||||
<attribute name="markerType" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Breakpoint's marker type for which the given attribute labels are applied.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="identifier"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="debugModelId" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Debug model Id of the active debug context for which this extension is valid. If not specified or if the model ID equals the CDT breakpoint's model (org.eclipse.cdt.debug.core), the option is always shown.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="identifier"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="attribute">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Each attribute entry displays or modifies a breakpoint attribute with the given ID.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<element ref="value"/>
|
||||
|
@ -88,28 +138,47 @@
|
|||
<documentation>
|
||||
user visible label for the breakpoint attribute value
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="fieldEditor" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
field editor that will be shown to for given attribute.
|
||||
If not specified this attribute will not be visible in Common page.
|
||||
Field editor that will be shown to for given attribute. This field editor must be on the classpath of the org.eclipse.cdt.debug.ui plugin. For a custom field editor use the newer fieldEditorFactory attribute. If this parameter is not specified, the org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor field editor will be used by default.
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn="org.eclipse.jface.preference.FieldEditor:"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="type" type="string" use="default" value="string">
|
||||
<attribute name="type" use="default" value="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Type of the attribute. Value should be one of "boolean", "string", "integer", "float".
|
||||
Type of the attribute. Value should be one of "boolean", "string", "integer", "float".
|
||||
</documentation>
|
||||
</annotation>
|
||||
<simpleType>
|
||||
<restriction base="string">
|
||||
<enumeration value="string">
|
||||
</enumeration>
|
||||
<enumeration value="integer">
|
||||
</enumeration>
|
||||
<enumeration value="float">
|
||||
</enumeration>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</attribute>
|
||||
<attribute name="fieldEditorFactory" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.debug.ui.breakpoints.IFieldEditorFactory"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
@ -117,8 +186,7 @@ If not specified this attribute will not be visible in Common page.
|
|||
<element name="value">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Properties of value for parent attribute.
|
||||
If Value contains child attributes it means that these property only enabled when value of parent attribute equal to current element value
|
||||
Properties of value for parent attribute. If a value elemnt contains child attribute elements it means that these property only enabled when value of parent attribute equal to current element value.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
|
@ -137,27 +205,27 @@ If Value contains child attributes it means that these property only enabled whe
|
|||
<documentation>
|
||||
User visible label for the breakpoint attribute value
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
CDT 5.0
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
<pre>
|
||||
<extension id="com.xyz.coolMarkerLabels" point="org.eclipse.cdt.debug.ui.breakpointContribution">
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.model.IDebugModelProvider;
|
||||
import org.eclipse.debug.core.model.ILineBreakpoint;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextProvider;
|
||||
|
@ -462,11 +463,12 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
|
|||
protected void createFieldEditors() {
|
||||
ICBreakpoint breakpoint = getBreakpoint();
|
||||
createMainLabel(breakpoint);
|
||||
createContributedFieldEditors(breakpoint);
|
||||
createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_LABELS);
|
||||
createTypeSpecificLabelFieldEditors( breakpoint );
|
||||
createEnabledField( getFieldEditorParent() );
|
||||
createConditionEditor( getFieldEditorParent() );
|
||||
createIgnoreCountEditor( getFieldEditorParent() );
|
||||
createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_EDITORS);
|
||||
}
|
||||
|
||||
private void createMainLabel(ICBreakpoint breakpoint) {
|
||||
|
@ -760,26 +762,34 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
|
|||
|
||||
/**
|
||||
* Creates field editors contributed using breakpointUIContribution extension point
|
||||
* @param breakpoint
|
||||
*/
|
||||
private void createContributedFieldEditors(ICBreakpoint breakpoint) {
|
||||
private void createContributedFieldEditors(ICBreakpoint breakpoint, String conMainElement) {
|
||||
Composite parent = getFieldEditorParent();
|
||||
String[] debugModelIds = CBreakpointUIContributionFactory.DEBUG_MODEL_IDS_DEFAULT;
|
||||
IDebugModelProvider debugModelProvider = (IDebugModelProvider)DebugPlugin.getAdapter(
|
||||
getDebugContext(), IDebugModelProvider.class);
|
||||
if (debugModelProvider != null) {
|
||||
debugModelIds = debugModelProvider.getModelIdentifiers();
|
||||
}
|
||||
|
||||
try {
|
||||
ICBreakpointsUIContribution[] cons;
|
||||
CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance();
|
||||
IPreferenceStore prefStore = getPreferenceStore();
|
||||
if (prefStore instanceof CBreakpointPreferenceStore) {
|
||||
cons = factory.getBreakpointUIContributions(
|
||||
breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes());
|
||||
debugModelIds, breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes());
|
||||
} else {
|
||||
cons = factory.getBreakpointUIContributions(breakpoint);
|
||||
}
|
||||
|
||||
for (ICBreakpointsUIContribution con : cons) {
|
||||
FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel()+":", parent); //$NON-NLS-1$
|
||||
if (fieldEditor != null) {
|
||||
addField(fieldEditor);
|
||||
}
|
||||
if ( conMainElement.equals(con.getMainElement()) ) {
|
||||
FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$
|
||||
if (fieldEditor != null) {
|
||||
addField(fieldEditor);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException ce) {
|
||||
CDebugUIPlugin.log(ce);
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
package org.eclipse.cdt.debug.ui.breakpoints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
|
@ -31,7 +33,6 @@ import org.eclipse.debug.core.model.IBreakpoint;
|
|||
|
||||
public class CBreakpointUIContributionFactory {
|
||||
private static final String EXTENSION_POINT_NAME = "breakpointContribution"; //$NON-NLS-1$
|
||||
private static final String MAIN_ELEMENT = "breakpointLabels"; //$NON-NLS-1$
|
||||
|
||||
private static CBreakpointUIContributionFactory instance;
|
||||
protected ArrayList<ICBreakpointsUIContribution> contributions;
|
||||
|
@ -70,22 +71,28 @@ public class CBreakpointUIContributionFactory {
|
|||
* @throws CoreException if cannot get marker attributes from bearkpoint
|
||||
* @since 7.2
|
||||
*/
|
||||
public ICBreakpointsUIContribution[] getBreakpointUIContributions(IBreakpoint breakpoint,
|
||||
Map<String, Object> attributes)
|
||||
throws CoreException
|
||||
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIDs, IBreakpoint breakpoint,
|
||||
Map<String, Object> attributes) throws CoreException
|
||||
{
|
||||
String debugModelId = breakpoint.getModelIdentifier();
|
||||
IMarker bmarker = breakpoint.getMarker();
|
||||
String markerType = CDIDebugModel.calculateMarkerType(breakpoint);
|
||||
if (bmarker != null) {
|
||||
markerType = bmarker.getType();
|
||||
}
|
||||
return getBreakpointUIContributions(debugModelId, markerType, attributes);
|
||||
return getBreakpointUIContributions(debugModelIDs, markerType, attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default debug model ID list which will cause only the general UI contributions to be returned.
|
||||
* @since 7.2
|
||||
*/
|
||||
public final static String[] DEBUG_MODEL_IDS_DEFAULT = new String[] {};
|
||||
|
||||
/**
|
||||
* Calculates the breakpoint UI contributions for the given breakpoint.
|
||||
*
|
||||
* @param debugModelId The debug model ID of the active debug context for
|
||||
* which to calculate contributions.
|
||||
* @param breakpoint Breakpoint to find UI contributions for.
|
||||
* @param markerType Marker type of the breakpoint.
|
||||
* @param attributes Attributes of the breakpoint
|
||||
|
@ -96,25 +103,54 @@ public class CBreakpointUIContributionFactory {
|
|||
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String debugModelId, String markerType,
|
||||
Map<String, Object> attributes)
|
||||
{
|
||||
ArrayList<ICBreakpointsUIContribution> list = new ArrayList<ICBreakpointsUIContribution>();
|
||||
for (ICBreakpointsUIContribution con : contributions) {
|
||||
try {
|
||||
if (debugModelId == null || con.getDebugModelId() == null || debugModelId.equals(con.getDebugModelId())) {
|
||||
String contributedMarkerType = con.getMarkerType();
|
||||
if (isMarkerSubtypeOf(markerType, contributedMarkerType)) {
|
||||
if (attributes == null || con.isApplicable(attributes)) {
|
||||
list.add(con);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CDebugUIPlugin.log(e);
|
||||
}
|
||||
|
||||
}
|
||||
return list.toArray(new ICBreakpointsUIContribution[list.size()]);
|
||||
return getBreakpointUIContributions(
|
||||
debugModelId != null ? new String[] { debugModelId } : DEBUG_MODEL_IDS_DEFAULT,
|
||||
markerType,
|
||||
attributes);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the breakpoint UI contributions for the given breakpoint.
|
||||
*
|
||||
* @param debugModelId The debug model IDs of the active debug context for
|
||||
* which to calculate contributions.
|
||||
* @param breakpoint Breakpoint to find UI contributions for.
|
||||
* @param markerType Marker type of the breakpoint.
|
||||
* @param attributes Attributes of the breakpoint
|
||||
* @return non-null array of ICBreakpointsUIContribution
|
||||
* @throws CoreException
|
||||
* @throws CoreException if cannot get marker attributes from berakpoint
|
||||
*
|
||||
* @since 7.2
|
||||
*/
|
||||
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIds, String markerType,
|
||||
Map<String, Object> attributes)
|
||||
{
|
||||
List<String> debugModelIdsList = Arrays.asList(debugModelIds);
|
||||
ArrayList<ICBreakpointsUIContribution> list = new ArrayList<ICBreakpointsUIContribution>();
|
||||
for (ICBreakpointsUIContribution con : contributions) {
|
||||
try {
|
||||
if (con.getDebugModelId() == null ||
|
||||
con.getDebugModelId().equals(CDIDebugModel.getPluginIdentifier()) ||
|
||||
debugModelIdsList.contains(con.getDebugModelId()))
|
||||
{
|
||||
String contributedMarkerType = con.getMarkerType();
|
||||
if (isMarkerSubtypeOf(markerType, contributedMarkerType)) {
|
||||
if (attributes == null || con.isApplicable(attributes)) {
|
||||
list.add(con);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CDebugUIPlugin.log(e);
|
||||
}
|
||||
|
||||
}
|
||||
return list.toArray(new ICBreakpointsUIContribution[list.size()]);
|
||||
}
|
||||
|
||||
|
||||
public boolean isMarkerSubtypeOf(String currentType, String type) throws CoreException {
|
||||
return getWorkspace().getMarkerManager().isSubtype(currentType, type);
|
||||
}
|
||||
|
@ -132,15 +168,19 @@ public class CBreakpointUIContributionFactory {
|
|||
IConfigurationElement[] elements = ep.getConfigurationElements();
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
IConfigurationElement configurationElement = elements[i];
|
||||
if (configurationElement.getName().equals(MAIN_ELEMENT)) {
|
||||
if (configurationElement.getName().equals(ICBreakpointsUIContribution.BREAKPOINT_LABELS) ||
|
||||
configurationElement.getName().equals(ICBreakpointsUIContribution.BREAKPOINT_EDITORS))
|
||||
{
|
||||
String mainElement = configurationElement.getName();
|
||||
String modelId = configurationElement.getAttribute("debugModelId"); //$NON-NLS-1$
|
||||
String markerType = getRequired(configurationElement, "markerType"); //$NON-NLS-1$
|
||||
if (markerType == null)
|
||||
continue;
|
||||
IConfigurationElement[] children = configurationElement.getChildren("attribute"); //$NON-NLS-1$
|
||||
for (IConfigurationElement att : children) {
|
||||
|
||||
DefaultCBreakpointUIContribution adapter = new DefaultCBreakpointUIContribution();
|
||||
|
||||
DefaultCBreakpointUIContribution adapter = new DefaultCBreakpointUIContribution(att);
|
||||
adapter.setMainElement(mainElement);
|
||||
adapter.setMarkerType(markerType);
|
||||
adapter.setDebugModelId(modelId);
|
||||
if (processAttribute(att, adapter) == false)
|
||||
|
@ -152,10 +192,13 @@ public class CBreakpointUIContributionFactory {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean processAttribute(IConfigurationElement attrElement, DefaultCBreakpointUIContribution adapter) {
|
||||
private boolean processAttribute(IConfigurationElement attrElement,
|
||||
DefaultCBreakpointUIContribution adapter)
|
||||
{
|
||||
String attrId = getRequired(attrElement, "name"); //$NON-NLS-1$
|
||||
String attrLabel = getRequired(attrElement, "label"); //$NON-NLS-1$
|
||||
String className = attrElement.getAttribute("fieldEditor"); //$NON-NLS-1$
|
||||
String fieldEditorClass = attrElement.getAttribute("fieldEditor"); //$NON-NLS-1$
|
||||
String fieldEditorFactoryClass = attrElement.getAttribute("fieldEditorFactory"); //$NON-NLS-1$
|
||||
String type = attrElement.getAttribute("type"); //$NON-NLS-1$
|
||||
String svisible = attrElement.getAttribute("visible"); //$NON-NLS-1$
|
||||
|
||||
|
@ -174,7 +217,8 @@ public class CBreakpointUIContributionFactory {
|
|||
}
|
||||
adapter.setId(attrId);
|
||||
adapter.setLabel(attrLabel);
|
||||
adapter.setControlClass(className);
|
||||
adapter.setControlClass(fieldEditorClass);
|
||||
adapter.setFieldEditorFactory(fieldEditorFactoryClass);
|
||||
adapter.setType(type);
|
||||
adapter.setVisible(visible);
|
||||
addContribution(adapter);
|
||||
|
@ -196,8 +240,9 @@ public class CBreakpointUIContributionFactory {
|
|||
adapter.addValue(valueId, valueLabel);
|
||||
IConfigurationElement[] children = valueElement.getChildren("attribute"); //$NON-NLS-1$
|
||||
for (IConfigurationElement att : children) {
|
||||
DefaultCBreakpointUIContribution adapter2 = new DefaultCBreakpointUIContribution();
|
||||
DefaultCBreakpointUIContribution adapter2 = new DefaultCBreakpointUIContribution(att);
|
||||
// inherit values
|
||||
adapter2.setMainElement(adapter.getMainElement());
|
||||
adapter2.setMarkerType(adapter.getMarkerType());
|
||||
adapter2.setDebugModelId(adapter.getDebugModelId());
|
||||
adapter2.addContionsAll(adapter.getConditions());
|
||||
|
|
|
@ -96,7 +96,7 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory {
|
|||
if (ignoreCount > 0) {
|
||||
label.append(' ');
|
||||
label.append(MessageFormat.format(
|
||||
DebugCoreMessages.getString("CDebugUtils.3"), new String[] { Integer.toString(ignoreCount) })); //$NON-NLS-1$
|
||||
DebugCoreMessages.getString("CDebugUtils.3"), new Object[] { Integer.toString(ignoreCount) })); //$NON-NLS-1$
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory {
|
|||
if (condition != null && condition.length() > 0) {
|
||||
buffer.append(' ');
|
||||
buffer.append(MessageFormat
|
||||
.format(DebugCoreMessages.getString("CDebugUtils.4"), new String[] { condition })); //$NON-NLS-1$
|
||||
.format(DebugCoreMessages.getString("CDebugUtils.4"), new Object[] { condition })); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,19 +20,31 @@ import java.util.Set;
|
|||
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.jface.preference.FieldEditor;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
||||
|
||||
private final IConfigurationElement fConfig;
|
||||
private String mainElement;
|
||||
private String attLabel;
|
||||
private String attId;
|
||||
private String fieldEditorClassName;
|
||||
private String fieldEditorFactoryClass;
|
||||
private IFieldEditorFactory fieldEditorFactory;
|
||||
private String markerType;
|
||||
private String modelId;
|
||||
private String attType;
|
||||
private Map<String, String> valueLabels = new LinkedHashMap<String, String>();
|
||||
private Map<String, String> conditions = new HashMap<String, String>();
|
||||
|
||||
DefaultCBreakpointUIContribution(IConfigurationElement config) {
|
||||
fConfig = config;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return attId;
|
||||
|
@ -48,28 +60,43 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
|||
return modelId;
|
||||
}
|
||||
|
||||
static private Class[] fieldSignature = new Class[] { String.class, String.class,
|
||||
@Override
|
||||
public String getMainElement() {
|
||||
return mainElement;
|
||||
}
|
||||
|
||||
static private Class<?>[] fieldSignature = new Class[] { String.class, String.class,
|
||||
Composite.class };
|
||||
|
||||
@Override
|
||||
public FieldEditor getFieldEditor(String name, String labelText, Composite parent) {
|
||||
String className = fieldEditorClassName;
|
||||
if (fieldEditorClassName == null) {
|
||||
className = ReadOnlyFieldEditor.class.getName();
|
||||
}
|
||||
try {
|
||||
Class cclass = Class.forName(className);
|
||||
Constructor constructor = cclass.getConstructor(fieldSignature);
|
||||
FieldEditor editor = (FieldEditor) constructor.newInstance(name, labelText, parent);
|
||||
if (editor instanceof ICBreakpointsUIContributionUser) {
|
||||
((ICBreakpointsUIContributionUser)editor).setContribution(this);
|
||||
}
|
||||
return editor;
|
||||
} catch (Exception e) {
|
||||
// cannot happened, would have happened when loading extension
|
||||
CDebugUIPlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
if (fieldEditorFactory != null) {
|
||||
return fieldEditorFactory.createFieldEditor(name, labelText, parent);
|
||||
} else if (fieldEditorFactoryClass != null) {
|
||||
try {
|
||||
fieldEditorFactory = (IFieldEditorFactory) fConfig.createExecutableExtension("fieldEditorFactory"); //$NON-NLS-1$
|
||||
} catch (CoreException e) {
|
||||
CDebugUIPlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
return fieldEditorFactory.createFieldEditor(name, labelText, parent);
|
||||
} else if (fieldEditorClassName != null) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<FieldEditor> cclass = (Class<FieldEditor>)Class.forName(fieldEditorClassName);
|
||||
Constructor<FieldEditor> constructor = cclass.getConstructor(fieldSignature);
|
||||
FieldEditor editor = constructor.newInstance(name, labelText, parent);
|
||||
if (editor instanceof ICBreakpointsUIContributionUser) {
|
||||
((ICBreakpointsUIContributionUser)editor).setContribution(this);
|
||||
}
|
||||
return editor;
|
||||
} catch (Exception e) {
|
||||
CDebugUIPlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return new ReadOnlyFieldEditor(name, labelText, parent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,7 +123,7 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(Map properties) {
|
||||
public boolean isApplicable(Map<String, Object> properties) {
|
||||
for (Object key : properties.keySet()) {
|
||||
String value = conditions.get(key);
|
||||
if (value != null) {
|
||||
|
@ -109,6 +136,10 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void setMainElement(String mainElement) {
|
||||
this.mainElement = mainElement;
|
||||
}
|
||||
|
||||
public void setLabel(String attLabel) {
|
||||
this.attLabel = attLabel;
|
||||
}
|
||||
|
@ -120,6 +151,10 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
|
|||
public void setControlClass(String controlClass) {
|
||||
this.fieldEditorClassName = controlClass;
|
||||
}
|
||||
|
||||
public void setFieldEditorFactory(String factoryClass) {
|
||||
fieldEditorFactoryClass = factoryClass;
|
||||
}
|
||||
|
||||
public void setMarkerType(String markerId) {
|
||||
this.markerType = markerId;
|
||||
|
|
|
@ -19,13 +19,33 @@ import org.eclipse.jface.preference.FieldEditor;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
|
||||
/**
|
||||
* Interface representing a contributed UI element for breakpoint properties
|
||||
* dialogs.
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
*/
|
||||
public interface ICBreakpointsUIContribution {
|
||||
|
||||
/**
|
||||
* Main element name of breakpoint labels extension element.
|
||||
* @since 7.2
|
||||
*/
|
||||
public static final String BREAKPOINT_LABELS = "breakpointLabels"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Main element name of breakpoint editors extension element.
|
||||
* @since 7.2
|
||||
*/
|
||||
public static final String BREAKPOINT_EDITORS = "breakpointEditors"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Attribute id
|
||||
* @return
|
||||
*/
|
||||
public String getId();
|
||||
|
||||
/**
|
||||
* Extenralizable label for this attribute id
|
||||
* @return
|
||||
|
@ -41,6 +61,14 @@ public interface ICBreakpointsUIContribution {
|
|||
*/
|
||||
public FieldEditor getFieldEditor(String name, String labelText, Composite parent);
|
||||
|
||||
/**
|
||||
* Returns the element name under which this attribute was added. The value should either be
|
||||
* "breakpointLabels" or "breakpointEditors".
|
||||
* @return Main element name.
|
||||
* @since 7.2
|
||||
*/
|
||||
public String getMainElement();
|
||||
|
||||
/**
|
||||
* Get raw field editor class name
|
||||
* @return class name
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.ui.breakpoints;
|
||||
|
||||
import org.eclipse.jface.preference.FieldEditor;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
/**
|
||||
* Factory for creating field editors contributed through the <code>
|
||||
* org.eclipse.cdt.debug.ui.breakpointContribution</code> extension point.
|
||||
* <p>
|
||||
* Field editors do not have a non-arg constructor, therefore custom editors
|
||||
* cannot be created directly by the extension point directly. This factory
|
||||
* allows clients to instantiate a custom field editor which is not on the class
|
||||
* path of the CDT debug UI plugin.
|
||||
* </p>
|
||||
* @since 7.2
|
||||
*/
|
||||
public interface IFieldEditorFactory {
|
||||
|
||||
/**
|
||||
* Creates a field editor with given parameters.
|
||||
*
|
||||
* @param name Field editor's property name.
|
||||
* @param labelText Field editors label.
|
||||
* @param parent Field editors parent control.
|
||||
* @return Newly created field editor.
|
||||
*/
|
||||
public FieldEditor createFieldEditor(String name, String labelText, Composite parent);
|
||||
}
|
|
@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
org.eclipse.ui.ide,
|
||||
org.eclipse.cdt.examples.dsf.pda,
|
||||
org.eclipse.cdt.dsf,
|
||||
org.eclipse.cdt.dsf.ui
|
||||
org.eclipse.cdt.dsf.ui,
|
||||
org.eclipse.cdt.debug.ui;bundle-version="7.2.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.cdt.examples.dsf.pda.ui,
|
||||
org.eclipse.cdt.examples.dsf.pda.ui.breakpoints,
|
||||
|
|
|
@ -110,5 +110,18 @@
|
|||
class="org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.VariablePersistableFactory"
|
||||
id="org.eclipse.cdt.examples.dsf.pda.ui.variablePersitableFactory">
|
||||
</factory>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.cdt.debug.ui.breakpointContribution">
|
||||
<breakpointEditors
|
||||
debugModelId="org.eclipse.cdt.examples.dsf.pda.debugModel"
|
||||
markerType="org.eclipse.cdt.debug.core.cWatchpointMarker">
|
||||
<attribute
|
||||
fieldEditorFactory="org.eclipse.cdt.examples.dsf.pda.ui.breakpoints.PDAWatchpointFunctionFieldEditorFactory"
|
||||
label="Function"
|
||||
name="FUNCTION_NAME"
|
||||
type="string">
|
||||
</attribute>
|
||||
</breakpointEditors>
|
||||
</extension> -->
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.examples.dsf.pda.ui.breakpoints;
|
||||
|
||||
import org.eclipse.cdt.debug.ui.breakpoints.IFieldEditorFactory;
|
||||
import org.eclipse.jface.preference.FieldEditor;
|
||||
import org.eclipse.jface.preference.StringFieldEditor;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PDAWatchpointFunctionFieldEditorFactory implements IFieldEditorFactory {
|
||||
|
||||
public FieldEditor createFieldEditor(String name, String labelText, Composite parent) {
|
||||
return new StringFieldEditor(name, labelText, parent);
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator;
|
||||
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2;
|
||||
|
@ -59,6 +60,11 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
|||
PDAWatchpoint.MODIFICATION
|
||||
};
|
||||
|
||||
private static final String[] fgCDTWatchpointAttributes = {
|
||||
IBreakpoint.ENABLED,
|
||||
PDAWatchpoint.FUNCTION_NAME,
|
||||
};
|
||||
|
||||
// PDA breakpoints translator doesn't keep any state and it doesn't
|
||||
// need to initialize or clean up.
|
||||
public void initialize(BreakpointsMediator2 mediator) {
|
||||
|
@ -71,8 +77,10 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
|||
private List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
|
||||
throws CoreException
|
||||
{
|
||||
if (bp instanceof ICLineBreakpoint) {
|
||||
if (bp instanceof ICLineBreakpoint) {
|
||||
return getCBreakpointAttributes((ICLineBreakpoint)bp, bpManagerEnabled);
|
||||
} else if (bp instanceof ICWatchpoint) {
|
||||
return getCWatchpointAttributes((ICWatchpoint)bp, bpManagerEnabled);
|
||||
} else {
|
||||
return getPDABreakpointAttributes(bp, bpManagerEnabled);
|
||||
}
|
||||
|
@ -112,7 +120,45 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
|||
retVal.add(attrs);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
private List<Map<String, Object>> getCWatchpointAttributes(ICWatchpoint bp, boolean bpManagerEnabled)
|
||||
throws CoreException
|
||||
{
|
||||
Map<String, Object> attrs = new HashMap<String, Object>();
|
||||
|
||||
// Check that the marker exists and retrieve its attributes.
|
||||
// Due to accepted race conditions, the breakpiont marker may become null
|
||||
// while this method is being invoked. In this case throw an exception
|
||||
// and let the caller handle it.
|
||||
IMarker marker = bp.getMarker();
|
||||
if (marker == null || !marker.exists()) {
|
||||
throw new DebugException(new Status(IStatus.ERROR, PDAPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Breakpoint marker does not exist", null));
|
||||
}
|
||||
// Suppress cast warning: platform is still on Java 1.3
|
||||
Map<String, Object> platformBpAttrs = marker.getAttributes();
|
||||
|
||||
// Copy breakpoint attributes.
|
||||
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_WATCHPOINT);
|
||||
attrs.put(PDABreakpoints.ATTR_BREAKPOINT_TYPE, PDABreakpoints.PDA_WATCHPOINT);
|
||||
attrs.put(PDAWatchpoint.VAR_NAME, platformBpAttrs.get(ICWatchpoint.EXPRESSION));
|
||||
attrs.put(PDAWatchpoint.ACCESS, platformBpAttrs.get(ICWatchpoint.READ));
|
||||
attrs.put(PDAWatchpoint.MODIFICATION, platformBpAttrs.get(ICWatchpoint.WRITE));
|
||||
|
||||
copyAttributes(platformBpAttrs, attrs, fgCDTWatchpointAttributes);
|
||||
|
||||
// If the breakpoint manager is disabled, override the enabled attribute.
|
||||
if (!bpManagerEnabled) {
|
||||
attrs.put(IBreakpoint.ENABLED, false);
|
||||
}
|
||||
|
||||
// The breakpoint mediator allows for multiple target-side breakpoints
|
||||
// to be created for each IDE breakpoint. Although in case of PDA this
|
||||
// feature is never used, we still have to return a list of attributes.
|
||||
List<Map<String, Object>> retVal = new ArrayList<Map<String, Object>>(1);
|
||||
retVal.add(attrs);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> getPDABreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
|
||||
throws CoreException
|
||||
{
|
||||
|
@ -178,7 +224,7 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
|
|||
|
||||
public boolean supportsBreakpoint(IBreakpoint bp) {
|
||||
return bp.getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL) ||
|
||||
bp instanceof ICLineBreakpoint;
|
||||
bp instanceof ICLineBreakpoint || bp instanceof ICWatchpoint;
|
||||
}
|
||||
|
||||
public void updateBreakpointsStatus(
|
||||
|
|
Loading…
Add table
Reference in a new issue