1 11 package org.eclipse.debug.core.model; 12 13 import org.eclipse.core.runtime.IStatus; 14 import org.eclipse.core.runtime.PlatformObject; 15 import org.eclipse.core.runtime.Status; 16 import org.eclipse.debug.core.DebugEvent; 17 import org.eclipse.debug.core.DebugException; 18 import org.eclipse.debug.core.DebugPlugin; 19 import org.eclipse.debug.core.ILaunch; 20 import org.eclipse.debug.core.ILaunchConfiguration; 21 22 29 public abstract class DebugElement extends PlatformObject implements IDebugElement { 30 31 private IDebugTarget fTarget; 32 33 39 public DebugElement(IDebugTarget target) { 40 fTarget = target; 41 } 42 43 49 public IDebugTarget getDebugTarget() { 50 return fTarget; 51 } 52 53 56 public ILaunch getLaunch() { 57 return getDebugTarget().getLaunch(); 58 } 59 60 63 public Object getAdapter(Class adapter) { 64 if (adapter == IDebugElement.class) { 65 return this; 66 } 67 68 if (adapter == IStepFilters.class) { 70 if (getDebugTarget() instanceof IStepFilters) 71 return getDebugTarget(); 72 } 73 if (adapter == IDebugTarget.class) { 74 return getDebugTarget(); 75 } 76 if (adapter == ILaunch.class) { 77 return getLaunch(); 78 } 79 if (adapter == IProcess.class) { 80 return getDebugTarget().getProcess(); 81 } 82 if(adapter == ILaunchConfiguration.class) { 84 return getLaunch().getLaunchConfiguration(); 85 } 86 return super.getAdapter(adapter); 87 } 88 89 94 public void fireEvent(DebugEvent event) { 95 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {event}); 96 } 97 98 105 public void fireChangeEvent(int detail) { 106 fireEvent(new DebugEvent(this, DebugEvent.CHANGE, detail)); 107 } 108 109 112 public void fireCreationEvent() { 113 fireEvent(new DebugEvent(this, DebugEvent.CREATE)); 114 } 115 116 123 public void fireResumeEvent(int detail) { 124 fireEvent(new DebugEvent(this, DebugEvent.RESUME, detail)); 125 } 126 127 134 public void fireSuspendEvent(int detail) { 135 fireEvent(new DebugEvent(this, DebugEvent.SUSPEND, detail)); 136 } 137 138 141 public void fireTerminateEvent() { 142 fireEvent(new DebugEvent(this, DebugEvent.TERMINATE)); 143 } 144 145 152 protected void requestFailed(String message, Throwable e) throws DebugException { 153 throw new DebugException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), 154 DebugException.TARGET_REQUEST_FAILED, message, e)); 155 } 156 157 164 protected void notSupported(String message, Throwable e) throws DebugException { 165 throw new DebugException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), 166 DebugException.NOT_SUPPORTED, message, e)); 167 } 168 } 169 | Popular Tags |