| /******************************************************************************* |
| * Copyright (c) 2009, 2019 Xored Software Inc and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-v20.html |
| * |
| * Contributors: |
| * Xored Software Inc - initial API and implementation and/or initial documentation |
| *******************************************************************************/ |
| package org.eclipse.rcptt.ecl.internal.debug.core; |
| |
| import org.eclipse.core.runtime.PlatformObject; |
| import org.eclipse.debug.core.DebugEvent; |
| import org.eclipse.debug.core.DebugException; |
| import org.eclipse.debug.core.DebugPlugin; |
| import org.eclipse.debug.core.ILaunch; |
| import org.eclipse.debug.core.model.IDebugElement; |
| import org.eclipse.debug.core.model.IDebugTarget; |
| import org.eclipse.rcptt.ecl.debug.core.EclDebug; |
| |
| public abstract class EclDebugElement extends PlatformObject implements |
| IDebugElement { |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() |
| */ |
| public String getModelIdentifier() { |
| return EclDebug.MODEL; |
| } |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see org.eclipse.debug.core.model.IDebugElement#getLaunch() |
| */ |
| public ILaunch getLaunch() { |
| return getDebugTarget().getLaunch(); |
| } |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
| */ |
| public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { |
| if (adapter == IDebugElement.class) { |
| return this; |
| } |
| if (adapter == IDebugTarget.class) { |
| return getDebugTarget(); |
| } |
| if (adapter == ILaunch.class) { |
| return getLaunch(); |
| } |
| |
| return super.getAdapter(adapter); |
| } |
| |
| protected void abort(String message, Throwable e) throws DebugException { |
| throw new DebugException(Plugin.status(message, e)); |
| } |
| |
| /** |
| * Fires a debug event |
| * |
| * @param event |
| * the event to be fired |
| */ |
| protected void fireEvent(DebugEvent event) { |
| DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { event }); |
| } |
| |
| /** |
| * Fires a <code>CREATE</code> event for this element. |
| */ |
| protected void fireCreationEvent() { |
| fireEvent(new DebugEvent(this, DebugEvent.CREATE)); |
| } |
| |
| /** |
| * Fires a <code>RESUME</code> event for this element with the given detail. |
| * |
| * @param detail |
| * event detail code |
| */ |
| public void fireResumeEvent(int detail) { |
| fireEvent(new DebugEvent(this, DebugEvent.RESUME, detail)); |
| } |
| |
| /** |
| * Fires a <code>SUSPEND</code> event for this element with the given |
| * detail. |
| * |
| * @param detail |
| * event detail code |
| */ |
| public void fireSuspendEvent(int detail) { |
| fireEvent(new DebugEvent(this, DebugEvent.SUSPEND, detail)); |
| } |
| |
| /** |
| * Fires a <code>TERMINATE</code> event for this element. |
| */ |
| protected void fireTerminateEvent() { |
| fireEvent(new DebugEvent(this, DebugEvent.TERMINATE)); |
| } |
| } |