1
0
Fork 0
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:
Pawel Piech 2012-03-27 14:18:32 -07:00
parent dce877458e
commit 6d107cd42e
13 changed files with 411 additions and 94 deletions

View file

@ -35,8 +35,8 @@ public interface ICBreakpoint extends IBreakpoint {
/** /**
* This debug model identifier can be returned by a debug implementation * This debug model identifier can be returned by a debug implementation
* to indicate that a given debugger integration is using C Breakpoints. * to indicate that a given debugger integration is using C Breakpoints.
* This model ID will allow breakpoint actions to configure their default * This model ID will allow toggle breakpoint actions to configure their
* selection. * default selection.
* *
* @since 7.0 * @since 7.0
*/ */

View file

@ -9,4 +9,11 @@
</message_arguments> </message_arguments>
</filter> </filter>
</resource> </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> </component>

View file

@ -2,18 +2,26 @@
<!-- Schema file written by PDE --> <!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.debug.ui" xmlns="http://www.w3.org/2001/XMLSchema"> <schema targetNamespace="org.eclipse.cdt.debug.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation> <annotation>
<appinfo> <appInfo>
<meta.schema plugin="org.eclipse.cdt.debug.ui" id="breakpointContribution" name="Breakpoint UI Contribution"/> <meta.schema plugin="org.eclipse.cdt.debug.ui" id="breakpointContribution" name="Breakpoint UI Contribution"/>
</appinfo> </appInfo>
<documentation> <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 &quot;Common&quot; 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> </documentation>
</annotation> </annotation>
<element name="extension"> <element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType> <complexType>
<sequence minOccurs="1" maxOccurs="unbounded"> <sequence minOccurs="1" maxOccurs="unbounded">
<element ref="breakpointLabels"/> <element ref="breakpointLabels" minOccurs="0" maxOccurs="unbounded"/>
<element ref="breakpointEditors" minOccurs="0" maxOccurs="unbounded"/>
</sequence> </sequence>
<attribute name="point" type="string" use="required"> <attribute name="point" type="string" use="required">
<annotation> <annotation>
@ -34,15 +42,20 @@
<documentation> <documentation>
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute translatable="true"/> <meta.attribute translatable="true"/>
</appinfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
</complexType> </complexType>
</element> </element>
<element name="breakpointLabels"> <element name="breakpointLabels">
<annotation>
<documentation>
A breakpoint label is appended to the top section the breakpoint properties common page.
</documentation>
</annotation>
<complexType> <complexType>
<sequence minOccurs="0" maxOccurs="unbounded"> <sequence minOccurs="0" maxOccurs="unbounded">
<element ref="attribute"/> <element ref="attribute"/>
@ -50,28 +63,65 @@
<attribute name="markerType" type="string"> <attribute name="markerType" type="string">
<annotation> <annotation>
<documentation> <documentation>
marker type for which attribute labels are applied Breakpoint&apos;s marker type for which the given attribute labels are applied.
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute kind="identifier"/> <meta.attribute kind="identifier"/>
</appinfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="debugModelId" type="string"> <attribute name="debugModelId" type="string">
<annotation> <annotation>
<documentation> <documentation>
debug model Id for this extension is valid 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&apos;s model (org.eclipse.cdt.debug.core), the option is always shown.
(debugModelId is a property of cbreakpoint)
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute kind="identifier"/> <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&apos;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&apos;s model (org.eclipse.cdt.debug.core), the option is always shown.
</documentation>
<appInfo>
<meta.attribute kind="identifier"/>
</appInfo>
</annotation> </annotation>
</attribute> </attribute>
</complexType> </complexType>
</element> </element>
<element name="attribute"> <element name="attribute">
<annotation>
<documentation>
Each attribute entry displays or modifies a breakpoint attribute with the given ID.
</documentation>
</annotation>
<complexType> <complexType>
<sequence minOccurs="0" maxOccurs="unbounded"> <sequence minOccurs="0" maxOccurs="unbounded">
<element ref="value"/> <element ref="value"/>
@ -88,28 +138,47 @@
<documentation> <documentation>
user visible label for the breakpoint attribute value user visible label for the breakpoint attribute value
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute translatable="true"/> <meta.attribute translatable="true"/>
</appinfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="fieldEditor" type="string"> <attribute name="fieldEditor" type="string">
<annotation> <annotation>
<documentation> <documentation>
field editor that will be shown to for given attribute. 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.
If not specified this attribute will not be visible in Common page.
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.jface.preference.FieldEditor:"/> <meta.attribute kind="java" basedOn="org.eclipse.jface.preference.FieldEditor:"/>
</appinfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="type" type="string" use="default" value="string"> <attribute name="type" use="default" value="string">
<annotation> <annotation>
<documentation> <documentation>
Type of the attribute. Value should be one of "boolean", "string", "integer", "float". Type of the attribute. Value should be one of &quot;boolean&quot;, &quot;string&quot;, &quot;integer&quot;, &quot;float&quot;.
</documentation> </documentation>
</annotation> </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> </attribute>
</complexType> </complexType>
</element> </element>
@ -117,8 +186,7 @@ If not specified this attribute will not be visible in Common page.
<element name="value"> <element name="value">
<annotation> <annotation>
<documentation> <documentation>
Properties of value for parent attribute. 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.
If Value contains child attributes it means that these property only enabled when value of parent attribute equal to current element value
</documentation> </documentation>
</annotation> </annotation>
<complexType> <complexType>
@ -137,27 +205,27 @@ If Value contains child attributes it means that these property only enabled whe
<documentation> <documentation>
User visible label for the breakpoint attribute value User visible label for the breakpoint attribute value
</documentation> </documentation>
<appinfo> <appInfo>
<meta.attribute translatable="true"/> <meta.attribute translatable="true"/>
</appinfo> </appInfo>
</annotation> </annotation>
</attribute> </attribute>
</complexType> </complexType>
</element> </element>
<annotation> <annotation>
<appinfo> <appInfo>
<meta.section type="since"/> <meta.section type="since"/>
</appinfo> </appInfo>
<documentation> <documentation>
CDT 5.0 CDT 5.0
</documentation> </documentation>
</annotation> </annotation>
<annotation> <annotation>
<appinfo> <appInfo>
<meta.section type="examples"/> <meta.section type="examples"/>
</appinfo> </appInfo>
<documentation> <documentation>
&lt;pre&gt; &lt;pre&gt;
&lt;extension id=&quot;com.xyz.coolMarkerLabels&quot; point=&quot;org.eclipse.cdt.debug.ui.breakpointContribution&quot;&gt; &lt;extension id=&quot;com.xyz.coolMarkerLabels&quot; point=&quot;org.eclipse.cdt.debug.ui.breakpointContribution&quot;&gt;

View file

@ -34,6 +34,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IDebugModelProvider;
import org.eclipse.debug.core.model.ILineBreakpoint; import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.contexts.IDebugContextProvider; import org.eclipse.debug.ui.contexts.IDebugContextProvider;
@ -462,11 +463,12 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
protected void createFieldEditors() { protected void createFieldEditors() {
ICBreakpoint breakpoint = getBreakpoint(); ICBreakpoint breakpoint = getBreakpoint();
createMainLabel(breakpoint); createMainLabel(breakpoint);
createContributedFieldEditors(breakpoint); createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_LABELS);
createTypeSpecificLabelFieldEditors( breakpoint ); createTypeSpecificLabelFieldEditors( breakpoint );
createEnabledField( getFieldEditorParent() ); createEnabledField( getFieldEditorParent() );
createConditionEditor( getFieldEditorParent() ); createConditionEditor( getFieldEditorParent() );
createIgnoreCountEditor( getFieldEditorParent() ); createIgnoreCountEditor( getFieldEditorParent() );
createContributedFieldEditors(breakpoint, ICBreakpointsUIContribution.BREAKPOINT_EDITORS);
} }
private void createMainLabel(ICBreakpoint breakpoint) { private void createMainLabel(ICBreakpoint breakpoint) {
@ -760,26 +762,34 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
/** /**
* Creates field editors contributed using breakpointUIContribution extension point * 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(); 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 { try {
ICBreakpointsUIContribution[] cons; ICBreakpointsUIContribution[] cons;
CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance(); CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance();
IPreferenceStore prefStore = getPreferenceStore(); IPreferenceStore prefStore = getPreferenceStore();
if (prefStore instanceof CBreakpointPreferenceStore) { if (prefStore instanceof CBreakpointPreferenceStore) {
cons = factory.getBreakpointUIContributions( cons = factory.getBreakpointUIContributions(
breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes()); debugModelIds, breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes());
} else { } else {
cons = factory.getBreakpointUIContributions(breakpoint); cons = factory.getBreakpointUIContributions(breakpoint);
} }
for (ICBreakpointsUIContribution con : cons) { for (ICBreakpointsUIContribution con : cons) {
FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel()+":", parent); //$NON-NLS-1$ if ( conMainElement.equals(con.getMainElement()) ) {
if (fieldEditor != null) { FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$
addField(fieldEditor); if (fieldEditor != null) {
} addField(fieldEditor);
}
}
} }
} catch (CoreException ce) { } catch (CoreException ce) {
CDebugUIPlugin.log(ce); CDebugUIPlugin.log(ce);

View file

@ -13,7 +13,9 @@
package org.eclipse.cdt.debug.ui.breakpoints; package org.eclipse.cdt.debug.ui.breakpoints;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
@ -31,7 +33,6 @@ import org.eclipse.debug.core.model.IBreakpoint;
public class CBreakpointUIContributionFactory { public class CBreakpointUIContributionFactory {
private static final String EXTENSION_POINT_NAME = "breakpointContribution"; //$NON-NLS-1$ 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; private static CBreakpointUIContributionFactory instance;
protected ArrayList<ICBreakpointsUIContribution> contributions; protected ArrayList<ICBreakpointsUIContribution> contributions;
@ -70,22 +71,28 @@ public class CBreakpointUIContributionFactory {
* @throws CoreException if cannot get marker attributes from bearkpoint * @throws CoreException if cannot get marker attributes from bearkpoint
* @since 7.2 * @since 7.2
*/ */
public ICBreakpointsUIContribution[] getBreakpointUIContributions(IBreakpoint breakpoint, public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIDs, IBreakpoint breakpoint,
Map<String, Object> attributes) Map<String, Object> attributes) throws CoreException
throws CoreException
{ {
String debugModelId = breakpoint.getModelIdentifier();
IMarker bmarker = breakpoint.getMarker(); IMarker bmarker = breakpoint.getMarker();
String markerType = CDIDebugModel.calculateMarkerType(breakpoint); String markerType = CDIDebugModel.calculateMarkerType(breakpoint);
if (bmarker != null) { if (bmarker != null) {
markerType = bmarker.getType(); 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. * 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 breakpoint Breakpoint to find UI contributions for.
* @param markerType Marker type of the breakpoint. * @param markerType Marker type of the breakpoint.
* @param attributes Attributes of the breakpoint * @param attributes Attributes of the breakpoint
@ -96,25 +103,54 @@ public class CBreakpointUIContributionFactory {
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String debugModelId, String markerType, public ICBreakpointsUIContribution[] getBreakpointUIContributions(String debugModelId, String markerType,
Map<String, Object> attributes) Map<String, Object> attributes)
{ {
ArrayList<ICBreakpointsUIContribution> list = new ArrayList<ICBreakpointsUIContribution>(); return getBreakpointUIContributions(
for (ICBreakpointsUIContribution con : contributions) { debugModelId != null ? new String[] { debugModelId } : DEBUG_MODEL_IDS_DEFAULT,
try { markerType,
if (debugModelId == null || con.getDebugModelId() == null || debugModelId.equals(con.getDebugModelId())) { attributes);
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()]);
} }
/**
* 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 { public boolean isMarkerSubtypeOf(String currentType, String type) throws CoreException {
return getWorkspace().getMarkerManager().isSubtype(currentType, type); return getWorkspace().getMarkerManager().isSubtype(currentType, type);
} }
@ -132,15 +168,19 @@ public class CBreakpointUIContributionFactory {
IConfigurationElement[] elements = ep.getConfigurationElements(); IConfigurationElement[] elements = ep.getConfigurationElements();
for (int i = 0; i < elements.length; i++) { for (int i = 0; i < elements.length; i++) {
IConfigurationElement configurationElement = elements[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 modelId = configurationElement.getAttribute("debugModelId"); //$NON-NLS-1$
String markerType = getRequired(configurationElement, "markerType"); //$NON-NLS-1$ String markerType = getRequired(configurationElement, "markerType"); //$NON-NLS-1$
if (markerType == null) if (markerType == null)
continue; continue;
IConfigurationElement[] children = configurationElement.getChildren("attribute"); //$NON-NLS-1$ IConfigurationElement[] children = configurationElement.getChildren("attribute"); //$NON-NLS-1$
for (IConfigurationElement att : children) { for (IConfigurationElement att : children) {
DefaultCBreakpointUIContribution adapter = new DefaultCBreakpointUIContribution(); DefaultCBreakpointUIContribution adapter = new DefaultCBreakpointUIContribution(att);
adapter.setMainElement(mainElement);
adapter.setMarkerType(markerType); adapter.setMarkerType(markerType);
adapter.setDebugModelId(modelId); adapter.setDebugModelId(modelId);
if (processAttribute(att, adapter) == false) 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 attrId = getRequired(attrElement, "name"); //$NON-NLS-1$
String attrLabel = getRequired(attrElement, "label"); //$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 type = attrElement.getAttribute("type"); //$NON-NLS-1$
String svisible = attrElement.getAttribute("visible"); //$NON-NLS-1$ String svisible = attrElement.getAttribute("visible"); //$NON-NLS-1$
@ -174,7 +217,8 @@ public class CBreakpointUIContributionFactory {
} }
adapter.setId(attrId); adapter.setId(attrId);
adapter.setLabel(attrLabel); adapter.setLabel(attrLabel);
adapter.setControlClass(className); adapter.setControlClass(fieldEditorClass);
adapter.setFieldEditorFactory(fieldEditorFactoryClass);
adapter.setType(type); adapter.setType(type);
adapter.setVisible(visible); adapter.setVisible(visible);
addContribution(adapter); addContribution(adapter);
@ -196,8 +240,9 @@ public class CBreakpointUIContributionFactory {
adapter.addValue(valueId, valueLabel); adapter.addValue(valueId, valueLabel);
IConfigurationElement[] children = valueElement.getChildren("attribute"); //$NON-NLS-1$ IConfigurationElement[] children = valueElement.getChildren("attribute"); //$NON-NLS-1$
for (IConfigurationElement att : children) { for (IConfigurationElement att : children) {
DefaultCBreakpointUIContribution adapter2 = new DefaultCBreakpointUIContribution(); DefaultCBreakpointUIContribution adapter2 = new DefaultCBreakpointUIContribution(att);
// inherit values // inherit values
adapter2.setMainElement(adapter.getMainElement());
adapter2.setMarkerType(adapter.getMarkerType()); adapter2.setMarkerType(adapter.getMarkerType());
adapter2.setDebugModelId(adapter.getDebugModelId()); adapter2.setDebugModelId(adapter.getDebugModelId());
adapter2.addContionsAll(adapter.getConditions()); adapter2.addContionsAll(adapter.getConditions());

View file

@ -96,7 +96,7 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory {
if (ignoreCount > 0) { if (ignoreCount > 0) {
label.append(' '); label.append(' ');
label.append(MessageFormat.format( 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; return label;
} }
@ -106,7 +106,7 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory {
if (condition != null && condition.length() > 0) { if (condition != null && condition.length() > 0) {
buffer.append(' '); buffer.append(' ');
buffer.append(MessageFormat 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$
} }
} }

View file

@ -20,19 +20,31 @@ import java.util.Set;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor; 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.jface.preference.FieldEditor;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution { class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
private final IConfigurationElement fConfig;
private String mainElement;
private String attLabel; private String attLabel;
private String attId; private String attId;
private String fieldEditorClassName; private String fieldEditorClassName;
private String fieldEditorFactoryClass;
private IFieldEditorFactory fieldEditorFactory;
private String markerType; private String markerType;
private String modelId; private String modelId;
private String attType; private String attType;
private Map<String, String> valueLabels = new LinkedHashMap<String, String>(); private Map<String, String> valueLabels = new LinkedHashMap<String, String>();
private Map<String, String> conditions = new HashMap<String, String>(); private Map<String, String> conditions = new HashMap<String, String>();
DefaultCBreakpointUIContribution(IConfigurationElement config) {
fConfig = config;
}
@Override @Override
public String getId() { public String getId() {
return attId; return attId;
@ -48,28 +60,43 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
return modelId; 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 }; Composite.class };
@Override @Override
public FieldEditor getFieldEditor(String name, String labelText, Composite parent) { public FieldEditor getFieldEditor(String name, String labelText, Composite parent) {
String className = fieldEditorClassName; if (fieldEditorFactory != null) {
if (fieldEditorClassName == null) { return fieldEditorFactory.createFieldEditor(name, labelText, parent);
className = ReadOnlyFieldEditor.class.getName(); } else if (fieldEditorFactoryClass != null) {
} try {
try { fieldEditorFactory = (IFieldEditorFactory) fConfig.createExecutableExtension("fieldEditorFactory"); //$NON-NLS-1$
Class cclass = Class.forName(className); } catch (CoreException e) {
Constructor constructor = cclass.getConstructor(fieldSignature); CDebugUIPlugin.log(e);
FieldEditor editor = (FieldEditor) constructor.newInstance(name, labelText, parent); return null;
if (editor instanceof ICBreakpointsUIContributionUser) { }
((ICBreakpointsUIContributionUser)editor).setContribution(this); return fieldEditorFactory.createFieldEditor(name, labelText, parent);
} } else if (fieldEditorClassName != null) {
return editor; try {
} catch (Exception e) { @SuppressWarnings("unchecked")
// cannot happened, would have happened when loading extension Class<FieldEditor> cclass = (Class<FieldEditor>)Class.forName(fieldEditorClassName);
CDebugUIPlugin.log(e); Constructor<FieldEditor> constructor = cclass.getConstructor(fieldSignature);
return null; 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 @Override
@ -96,7 +123,7 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
} }
@Override @Override
public boolean isApplicable(Map properties) { public boolean isApplicable(Map<String, Object> properties) {
for (Object key : properties.keySet()) { for (Object key : properties.keySet()) {
String value = conditions.get(key); String value = conditions.get(key);
if (value != null) { if (value != null) {
@ -109,6 +136,10 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
return true; return true;
} }
public void setMainElement(String mainElement) {
this.mainElement = mainElement;
}
public void setLabel(String attLabel) { public void setLabel(String attLabel) {
this.attLabel = attLabel; this.attLabel = attLabel;
} }
@ -120,6 +151,10 @@ class DefaultCBreakpointUIContribution implements ICBreakpointsUIContribution {
public void setControlClass(String controlClass) { public void setControlClass(String controlClass) {
this.fieldEditorClassName = controlClass; this.fieldEditorClassName = controlClass;
} }
public void setFieldEditorFactory(String factoryClass) {
fieldEditorFactoryClass = factoryClass;
}
public void setMarkerType(String markerId) { public void setMarkerType(String markerId) {
this.markerType = markerId; this.markerType = markerId;

View file

@ -19,13 +19,33 @@ import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.swt.widgets.Composite; 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 { 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 * Attribute id
* @return * @return
*/ */
public String getId(); public String getId();
/** /**
* Extenralizable label for this attribute id * Extenralizable label for this attribute id
* @return * @return
@ -41,6 +61,14 @@ public interface ICBreakpointsUIContribution {
*/ */
public FieldEditor getFieldEditor(String name, String labelText, Composite parent); 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 * Get raw field editor class name
* @return class name * @return class name

View file

@ -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);
}

View file

@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.ide, org.eclipse.ui.ide,
org.eclipse.cdt.examples.dsf.pda, org.eclipse.cdt.examples.dsf.pda,
org.eclipse.cdt.dsf, 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 Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.cdt.examples.dsf.pda.ui, Export-Package: org.eclipse.cdt.examples.dsf.pda.ui,
org.eclipse.cdt.examples.dsf.pda.ui.breakpoints, org.eclipse.cdt.examples.dsf.pda.ui.breakpoints,

View file

@ -110,5 +110,18 @@
class="org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.VariablePersistableFactory" class="org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.VariablePersistableFactory"
id="org.eclipse.cdt.examples.dsf.pda.ui.variablePersitableFactory"> id="org.eclipse.cdt.examples.dsf.pda.ui.variablePersitableFactory">
</factory> </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> --> </extension> -->
</plugin> </plugin>

View file

@ -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);
}
}

View file

@ -16,6 +16,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; 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.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator; import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator;
import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2; import org.eclipse.cdt.dsf.debug.service.BreakpointsMediator2;
@ -59,6 +60,11 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
PDAWatchpoint.MODIFICATION PDAWatchpoint.MODIFICATION
}; };
private static final String[] fgCDTWatchpointAttributes = {
IBreakpoint.ENABLED,
PDAWatchpoint.FUNCTION_NAME,
};
// PDA breakpoints translator doesn't keep any state and it doesn't // PDA breakpoints translator doesn't keep any state and it doesn't
// need to initialize or clean up. // need to initialize or clean up.
public void initialize(BreakpointsMediator2 mediator) { public void initialize(BreakpointsMediator2 mediator) {
@ -71,8 +77,10 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
private List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled) private List<Map<String, Object>> getBreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
throws CoreException throws CoreException
{ {
if (bp instanceof ICLineBreakpoint) { if (bp instanceof ICLineBreakpoint) {
return getCBreakpointAttributes((ICLineBreakpoint)bp, bpManagerEnabled); return getCBreakpointAttributes((ICLineBreakpoint)bp, bpManagerEnabled);
} else if (bp instanceof ICWatchpoint) {
return getCWatchpointAttributes((ICWatchpoint)bp, bpManagerEnabled);
} else { } else {
return getPDABreakpointAttributes(bp, bpManagerEnabled); return getPDABreakpointAttributes(bp, bpManagerEnabled);
} }
@ -112,7 +120,45 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
retVal.add(attrs); retVal.add(attrs);
return retVal; 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) private List<Map<String, Object>> getPDABreakpointAttributes(IBreakpoint bp, boolean bpManagerEnabled)
throws CoreException throws CoreException
{ {
@ -178,7 +224,7 @@ public class PDABreakpointAttributeTranslator implements IBreakpointAttributeTra
public boolean supportsBreakpoint(IBreakpoint bp) { public boolean supportsBreakpoint(IBreakpoint bp) {
return bp.getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL) || return bp.getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL) ||
bp instanceof ICLineBreakpoint; bp instanceof ICLineBreakpoint || bp instanceof ICWatchpoint;
} }
public void updateBreakpointsStatus( public void updateBreakpointsStatus(