Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2008-03-11 14:12:15 +0000
committerDarin Wright2008-03-11 14:12:15 +0000
commitf15186e80aca5851777aeaf557f81f3fd393d6d3 (patch)
tree93d63179ff117f5633d92362c27c11171045f270 /org.eclipse.debug.core
parentc2da19dc5b67c12bf510e8505bb3165264637460 (diff)
downloadeclipse.platform.debug-f15186e80aca5851777aeaf557f81f3fd393d6d3.tar.gz
eclipse.platform.debug-f15186e80aca5851777aeaf557f81f3fd393d6d3.tar.xz
eclipse.platform.debug-f15186e80aca5851777aeaf557f81f3fd393d6d3.zip
Bug 222228 - Should delegate to platform adapater manager for adapters
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java32
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommand.java13
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java8
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java8
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepCommand.java7
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java3
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/SuspendCommand.java8
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/TerminateCommand.java8
8 files changed, 51 insertions, 36 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
index 3e3aa8467..f54a05ba6 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
@@ -30,6 +30,7 @@ import org.eclipse.core.resources.ISaveContext;
import org.eclipse.core.resources.ISaveParticipant;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
@@ -38,6 +39,7 @@ import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
@@ -1373,6 +1375,36 @@ public class DebugPlugin extends Plugin {
return ((LaunchManager)getDefault().getLaunchManager()).getStepFilterManager();
}
+ /**
+ * Returns an adapter of the specified type for the given object or <code>null</code>
+ * if none. The object itself is returned if it is an instance of the specified type.
+ * If the object is adaptable and does not subclass <code>PlatformObject</code>, and
+ * does not provide the specified adapter directly, the platform's adapter manager
+ * is consulted for an adapter.
+ *
+ * @param element element to retrieve adapter for
+ * @param type adapter type
+ * @return adapter or <code>null</code>
+ * @since 3.4
+ */
+ public static Object getAdapter(Object element, Class type) {
+ Object adapter = null;
+ if (element != null) {
+ if (type.isInstance(element)) {
+ return element;
+ } else {
+ if (element instanceof IAdaptable) {
+ adapter = ((IAdaptable)element).getAdapter(type);
+ }
+ // for objects that don't subclass PlatformObject, check the platform's adapter manager
+ if (adapter == null && !(element instanceof PlatformObject)) {
+ adapter = Platform.getAdapterManager().getAdapter(element, type);
+ }
+ }
+ }
+ return adapter;
+ }
+
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommand.java
index dff79eb20..0286472f4 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DebugCommand.java
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IRequest;
import org.eclipse.debug.core.commands.IDebugCommandHandler;
import org.eclipse.debug.core.commands.IDebugCommandRequest;
@@ -205,6 +206,18 @@ public abstract class DebugCommand implements IDebugCommandHandler {
protected abstract Object getTarget(Object element);
/**
+ * Returns an adapter of the specified type for the given object or <code>null</code>
+ * if none. The object itself is returned if it is an instance of the specified type.
+ *
+ * @param element element to retrieve adapter for
+ * @param type adapter type
+ * @return adapter or <code>null</code>
+ */
+ protected Object getAdapter(Object element, Class type) {
+ return DebugPlugin.getAdapter(element, type);
+ }
+
+ /**
* Scheduling rule for updating command enabled state.
*
* @return scheduling rule or <code>null</code>
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java
index 66d33d438..40ca2d567 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java
@@ -11,7 +11,6 @@
package org.eclipse.debug.internal.core.commands;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.commands.IDisconnectHandler;
import org.eclipse.debug.core.model.IDisconnect;
@@ -23,12 +22,7 @@ import org.eclipse.debug.core.model.IDisconnect;
public class DisconnectCommand extends ForEachCommand implements IDisconnectHandler {
protected Object getTarget(Object element) {
- if (element instanceof IDisconnect) {
- return element;
- } else if (element instanceof IAdaptable) {
- return ((IAdaptable) element).getAdapter(IDisconnect.class);
- }
- return null;
+ return getAdapter(element, IDisconnect.class);
}
/* (non-Javadoc)
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java
index 06a3b937e..ceb191c26 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java
@@ -11,7 +11,6 @@
package org.eclipse.debug.internal.core.commands;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.commands.IDropToFrameHandler;
import org.eclipse.debug.core.model.IDropToFrame;
@@ -23,12 +22,7 @@ import org.eclipse.debug.core.model.IDropToFrame;
public class DropToFrameCommand extends StepCommand implements IDropToFrameHandler {
protected Object getTarget(Object element) {
- if (element instanceof IDropToFrame) {
- return element;
- } else if (element instanceof IAdaptable) {
- return ((IAdaptable) element).getAdapter(IDropToFrame.class);
- }
- return null;
+ return getAdapter(element, IDropToFrame.class);
}
/* (non-Javadoc)
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepCommand.java
index 94dd06572..8c01a4a47 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepCommand.java
@@ -75,12 +75,7 @@ public abstract class StepCommand extends DebugCommand {
}
protected Object getTarget(Object element) {
- if (element instanceof IStep) {
- return element;
- } else if (element instanceof IAdaptable) {
- return ((IAdaptable) element).getAdapter(IStep.class);
- }
- return null;
+ return getAdapter(element, IStep.class);
}
}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java
index bf594f511..108a159a5 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java
@@ -11,7 +11,6 @@
package org.eclipse.debug.internal.core.commands;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.commands.IStepFiltersHandler;
@@ -36,7 +35,7 @@ public class StepFiltersCommand extends ForEachCommand implements IStepFiltersHa
if (target instanceof IStepFilters) {
filters[i] = (IStepFilters) target;
} else {
- filters[i] = (IStepFilters) ((IAdaptable)element).getAdapter(IStepFilters.class);
+ filters[i] = (IStepFilters) getAdapter(element, IStepFilters.class);
}
if (filters[i] == null) {
return null;
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/SuspendCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/SuspendCommand.java
index 49717bfea..2150dd98d 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/SuspendCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/SuspendCommand.java
@@ -11,7 +11,6 @@
package org.eclipse.debug.internal.core.commands;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.commands.ISuspendHandler;
import org.eclipse.debug.core.model.ISuspendResume;
@@ -23,12 +22,7 @@ import org.eclipse.debug.core.model.ISuspendResume;
public class SuspendCommand extends ForEachCommand implements ISuspendHandler {
protected Object getTarget(Object element) {
- if (element instanceof ISuspendResume) {
- return element;
- } else if (element instanceof IAdaptable) {
- return ((IAdaptable) element).getAdapter(ISuspendResume.class);
- }
- return null;
+ return getAdapter(element, ISuspendResume.class);
}
protected void execute(Object target) throws CoreException {
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/TerminateCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/TerminateCommand.java
index 0cca66440..aa09b8aba 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/TerminateCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/TerminateCommand.java
@@ -11,7 +11,6 @@
package org.eclipse.debug.internal.core.commands;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.commands.ITerminateHandler;
import org.eclipse.debug.core.model.ITerminate;
@@ -23,12 +22,7 @@ import org.eclipse.debug.core.model.ITerminate;
public class TerminateCommand extends ForEachCommand implements ITerminateHandler {
protected Object getTarget(Object element) {
- if (element instanceof ITerminate) {
- return element;
- } else if (element instanceof IAdaptable) {
- return ((IAdaptable) element).getAdapter(ITerminate.class);
- }
- return null;
+ return getAdapter(element, ITerminate.class);
}
protected void execute(Object target) throws CoreException {

Back to the top