Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjszursze2001-09-24 13:10:42 +0000
committerjszursze2001-09-24 13:10:42 +0000
commit624b59c86aebe464debaf2edb15170f34cc7126b (patch)
tree267da22c0a2ba59f765ed1ade292175ed0f70d44
parente4147926c35efe6f2f17c95d1d81559fa5ddfedc (diff)
downloadeclipse.platform.debug-624b59c86aebe464debaf2edb15170f34cc7126b.tar.gz
eclipse.platform.debug-624b59c86aebe464debaf2edb15170f34cc7126b.tar.xz
eclipse.platform.debug-624b59c86aebe464debaf2edb15170f34cc7126b.zip
1GAURLB: ITPDUI:WINNT - Breakpoint properties
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/model/Breakpoint.java12
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/model/IBreakpoint.java3
-rw-r--r--org.eclipse.debug.ui/plugin.properties2
-rw-r--r--org.eclipse.debug.ui/plugin.xml1
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BreakpointPropertiesAdapterFactory.java76
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BreakpointsView.java3
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java6
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointPropertySource.java123
8 files changed, 222 insertions, 4 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/Breakpoint.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/Breakpoint.java
index 19bfe199b..cc7b35296 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/Breakpoint.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/Breakpoint.java
@@ -1,9 +1,8 @@
package org.eclipse.debug.core.model;
-import java.util.Map;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.IDebugConstants;
/**
@@ -13,7 +12,7 @@ import org.eclipse.debug.core.IDebugConstants;
*/
public abstract class Breakpoint implements IBreakpoint {
-
+
/**
* Underlying marker.
*/
@@ -69,6 +68,13 @@ public abstract class Breakpoint implements IBreakpoint {
public IMarker getMarker() {
return fMarker;
}
+
+ /**
+ * @see IAdaptable#getAdapter(Class adapter)
+ */
+ public Object getAdapter(Class adapter) {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IBreakpoint.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IBreakpoint.java
index 110a58364..7e125b892 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IBreakpoint.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IBreakpoint.java
@@ -2,6 +2,7 @@ package org.eclipse.debug.core.model;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
/**
* A breakpoint is capable of suspending the execution of a
@@ -44,7 +45,7 @@ import org.eclipse.core.runtime.CoreException;
* is then called to associated a marker with the breakpoint.
*/
-public interface IBreakpoint {
+public interface IBreakpoint extends IAdaptable {
/**
* Deletes this breakpoint's underlying marker, and removes
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties
index 877ec546a..779ecaf08 100644
--- a/org.eclipse.debug.ui/plugin.properties
+++ b/org.eclipse.debug.ui/plugin.properties
@@ -18,6 +18,8 @@
DebugModelPresentationExtensionName=Debug Model Presentation
+ BreakpointPropertyAdapterName=Breakpoint Property Adapter
+
RunAction.label=Run
RunAction.tooltip=Run
DebugAction.label=Debug
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index f97adbe94..1f145d9db 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -23,6 +23,7 @@
<!-- Extension points -->
<extension-point id="debugModelPresentations" name="%DebugModelPresentationExtensionName"/>
+<extension-point id="breakpointPropertyAdapters" name="%BreakpointPropertyAdapterName"/>
<!-- Extensions -->
<extension
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BreakpointPropertiesAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BreakpointPropertiesAdapterFactory.java
new file mode 100644
index 000000000..160f9b858
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BreakpointPropertiesAdapterFactory.java
@@ -0,0 +1,76 @@
+package org.eclipse.debug.internal.ui;
+
+import java.util.HashMap;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugConstants;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.ui.BreakpointPropertySource;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/*package*/ class BreakpointPropertiesAdapterFactory implements IAdapterFactory {
+
+ /**
+ * The configuration elements for all breakpoint extensions keyed by marker type
+ */
+ private static HashMap fAdapterExtensions = new HashMap(5);
+
+ /**
+ * Load the adapter extension map only once
+ */
+ static {
+ IExtensionPoint ep= DebugUIPlugin.getDefault().getDescriptor().getExtensionPoint("breakpointPropertyAdapters");
+ IConfigurationElement[] elements = ep.getConfigurationElements();
+ for (int i= 0; i < elements.length; i++) {
+ fAdapterExtensions.put(elements[i].getAttribute(IDebugConstants.MARKER_TYPE), elements[i]);
+ }
+ }
+
+ /**
+ * @see IAdapterFactory#getAdapter(Object, Class)
+ * If asked for an IPropertySource adapter for an IBreakpoint, find the configuration
+ * element that corresponds to the precise type of breakpoint, then create an instance
+ * of the 'propertyAdapterClass' exectuable extension and return it.
+ */
+ public Object getAdapter(Object obj, Class adapterType) {
+ if (adapterType.isInstance(obj)) {
+ return obj;
+ }
+ if (adapterType == IPropertySource.class) {
+ if (obj instanceof IBreakpoint) {
+ IBreakpoint breakpoint = (IBreakpoint) obj;
+ IMarker marker = breakpoint.getMarker();
+ try {
+ IConfigurationElement config = (IConfigurationElement)fAdapterExtensions.get(marker.getType());
+ IPropertySource propertySource = (IPropertySource)config.createExecutableExtension("class");
+ // If no adapter was specified, use the default adapter
+ if (propertySource == null) {
+ propertySource = new BreakpointPropertySource();
+ }
+ propertySource.setPropertyValue("breakpoint", breakpoint);
+ return propertySource;
+ } catch (CoreException ce) {
+ ce.printStackTrace();
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see IAdapterFactory#getAdapterList()
+ */
+ public Class[] getAdapterList() {
+ return new Class[] {
+ IPropertySource.class
+ };
+ }
+
+}
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BreakpointsView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BreakpointsView.java
index c38e785e9..120bc8524 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BreakpointsView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BreakpointsView.java
@@ -65,6 +65,9 @@ public class BreakpointsView extends AbstractDebugView implements IDoubleClickLi
WorkbenchHelp.setHelp(
parent,
new ViewContextComputer(this, IDebugHelpContextIds.BREAKPOINT_VIEW));
+
+ // Necessary so that the PropertySheetView hears about selections in this view
+ getSite().setSelectionProvider(fViewer);
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
index 9426e277b..2464396c4 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
@@ -698,6 +698,12 @@ public static Object createExtension(final IConfigurationElement element, final
for (int i = 0; i < launches.length; i++) {
launchRegistered(launches[i]);
}
+
+ // Create & register the adapter factory that will dispense objects that
+ // know about the properties that different breakpoint types support
+ IAdapterFactory factory = new BreakpointPropertiesAdapterFactory();
+ Platform.getAdapterManager().registerAdapters(factory, IBreakpoint.class);
+
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointPropertySource.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointPropertySource.java
new file mode 100644
index 000000000..5963e7c00
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointPropertySource.java
@@ -0,0 +1,123 @@
+package org.eclipse.debug.ui;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+/**
+ * Handles properties for instances of IBreakpoint
+ */
+public class BreakpointPropertySource implements IPropertySource {
+
+ protected IBreakpoint fBreakpoint;
+
+ /**
+ * The property descriptors that are common to all IBreakpoints
+ */
+ private static IPropertyDescriptor[] fBaseDescriptors;
+
+ // Property Values
+ protected static final String P_ID_ENABLE = "enable";
+
+ private static final String P_ENABLE = "enabled";
+
+ protected static final String P_VALUE_TRUE_LABEL = "true";
+ protected static final String P_VALUE_FALSE_LABEL = "false";
+
+ protected static final Integer P_VALUE_TRUE = new Integer(0);
+ protected static final Integer P_VALUE_FALSE = new Integer(1);
+
+ protected static String[] BOOLEAN_LABEL_ARRAY = new String[] {P_VALUE_TRUE_LABEL, P_VALUE_FALSE_LABEL};
+
+ public static class BooleanLabelProvider extends LabelProvider {
+ public String getText(Object element) {
+ String[] values = new String[] {P_VALUE_TRUE_LABEL, P_VALUE_FALSE_LABEL};
+ return values[((Integer)element).intValue()];
+ }
+ }
+
+ static {
+ fBaseDescriptors = new IPropertyDescriptor[1];
+ PropertyDescriptor propertyDescriptor;
+
+ propertyDescriptor = new ComboBoxPropertyDescriptor(P_ID_ENABLE, P_ENABLE, BOOLEAN_LABEL_ARRAY);
+ propertyDescriptor.setLabelProvider(new BooleanLabelProvider());
+ fBaseDescriptors[0] = propertyDescriptor;
+ }
+
+ /**
+ * @see IPropertySource#getEditableValue()
+ */
+ public Object getEditableValue() {
+ return this;
+ }
+
+ /**
+ * @see IPropertySource#getPropertyDescriptors()
+ */
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return fBaseDescriptors;
+ }
+
+ /**
+ * @see IPropertySource#getPropertyValue(Object)
+ */
+ public Object getPropertyValue(Object id) {
+ if (id.equals(P_ID_ENABLE)) {
+ try {
+ return fBreakpoint.isEnabled() ? P_VALUE_TRUE : P_VALUE_FALSE;
+ } catch (CoreException ce) {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see IPropertySource#isPropertySet(Object)
+ */
+ public boolean isPropertySet(Object id) {
+ return false;
+ }
+
+ /**
+ * @see IPropertySource#resetPropertyValue(Object)
+ */
+ public void resetPropertyValue(Object id) {
+ }
+
+ /**
+ * @see IPropertySource#setPropertyValue(Object, Object)
+ */
+ public void setPropertyValue(Object id, Object value) {
+ // To avoid requiring an extension to IPropertySource that includes API
+ // to set the breakpoint, we use this method in a somewhat non-inutuitive way.
+ // Note we can't set the breakpoint through a constructor since this object is
+ // created as an executable extension, which requires a no-arg constructor.
+ if (id.equals("breakpoint")) {
+ fBreakpoint = (IBreakpoint) value;
+ }
+ else if (id.equals(P_ID_ENABLE)) {
+ try {
+ fBreakpoint.setEnabled(((Integer)value).equals(P_VALUE_TRUE) ? true : false);
+ } catch (CoreException ce) {
+ }
+ }
+ }
+
+ /**
+ * Convenience method to get the model presentation text for a debug object
+ */
+ protected String getModelPresentationText(Object obj) {
+ return DebugUIPlugin.getModelPresentation().getText(obj);
+ }
+
+}
+

Back to the top