Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorPawel Piech2012-03-27 17:18:32 -0400
committerPawel Piech2012-04-03 17:17:57 -0400
commit6d107cd42e7ff103990077ed23731619d04d0522 (patch)
tree1d5569327262f8e1a8ad9c114ac7777b49dcff90 /debug
parentdce877458e94b789059f8577454d07f2e1b00bb0 (diff)
downloadorg.eclipse.cdt-6d107cd42e7ff103990077ed23731619d04d0522.tar.gz
org.eclipse.cdt-6d107cd42e7ff103990077ed23731619d04d0522.tar.xz
org.eclipse.cdt-6d107cd42e7ff103990077ed23731619d04d0522.zip
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
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java4
-rw-r--r--debug/org.eclipse.cdt.debug.ui/.settings/.api_filters7
-rw-r--r--debug/org.eclipse.cdt.debug.ui/schema/BreakpointUIContribution.exsd126
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java26
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java105
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java4
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/DefaultCBreakpointUIContribution.java73
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java28
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IFieldEditorFactory.java38
9 files changed, 321 insertions, 90 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java
index 0d85e473e3..565ac48f29 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICBreakpoint.java
@@ -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
*/
diff --git a/debug/org.eclipse.cdt.debug.ui/.settings/.api_filters b/debug/org.eclipse.cdt.debug.ui/.settings/.api_filters
index 48c6c7be8f..e8df87ef67 100644
--- a/debug/org.eclipse.cdt.debug.ui/.settings/.api_filters
+++ b/debug/org.eclipse.cdt.debug.ui/.settings/.api_filters
@@ -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>
diff --git a/debug/org.eclipse.cdt.debug.ui/schema/BreakpointUIContribution.exsd b/debug/org.eclipse.cdt.debug.ui/schema/BreakpointUIContribution.exsd
index d9b6c850f5..75e7f9ff50 100644
--- a/debug/org.eclipse.cdt.debug.ui/schema/BreakpointUIContribution.exsd
+++ b/debug/org.eclipse.cdt.debug.ui/schema/BreakpointUIContribution.exsd
@@ -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 &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>
</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&apos;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&apos;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&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>
</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,27 +138,46 @@
<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" use="default" value="string">
+ <annotation>
+ <documentation>
+ Type of the attribute. Value should be one of &quot;boolean&quot;, &quot;string&quot;, &quot;integer&quot;, &quot;float&quot;.
+ </documentation>
</annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="string">
+ </enumeration>
+ <enumeration value="integer">
+ </enumeration>
+ <enumeration value="float">
+ </enumeration>
+ </restriction>
+ </simpleType>
</attribute>
- <attribute name="type" type="string" use="default" value="string">
+ <attribute name="fieldEditorFactory" type="string">
<annotation>
<documentation>
- Type of the attribute. Value should be one of "boolean", "string", "integer", "float".
+
</documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.debug.ui.breakpoints.IFieldEditorFactory"/>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -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>
&lt;pre&gt;
&lt;extension id=&quot;com.xyz.coolMarkerLabels&quot; point=&quot;org.eclipse.cdt.debug.ui.breakpointContribution&quot;&gt;
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java
index 68b8a6beb2..22626082fb 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java
@@ -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);
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java
index 9631e55c38..118d1b4b79 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java
@@ -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());
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java
index 53c76328c1..953ba4eb1a 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java
@@ -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$
}
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/DefaultCBreakpointUIContribution.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/DefaultCBreakpointUIContribution.java
index 65c2bc8139..00d5b6107b 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/DefaultCBreakpointUIContribution.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/DefaultCBreakpointUIContribution.java
@@ -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;
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java
index a0a5aaf2c9..a21489d4fe 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/ICBreakpointsUIContribution.java
@@ -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
@@ -42,6 +62,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
*/
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IFieldEditorFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IFieldEditorFactory.java
new file mode 100644
index 0000000000..0ccb6f985d
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IFieldEditorFactory.java
@@ -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);
+}

Back to the top