diff options
author | Darin Wright | 2004-12-08 16:53:46 +0000 |
---|---|---|
committer | Darin Wright | 2004-12-08 16:53:46 +0000 |
commit | aa1abf9c1d59d8d08fbd776503af6712fa5d09d4 (patch) | |
tree | 7b5a1f736e714051286a88a08e266eee7e3c6e6e /org.eclipse.debug.core | |
parent | 41bfcade84ca5162fa84af1bfdfd2c64bfc172ba (diff) | |
download | eclipse.platform.debug-aa1abf9c1d59d8d08fbd776503af6712fa5d09d4.tar.gz eclipse.platform.debug-aa1abf9c1d59d8d08fbd776503af6712fa5d09d4.tar.xz eclipse.platform.debug-aa1abf9c1d59d8d08fbd776503af6712fa5d09d4.zip |
abstract debug element API - draft
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r-- | org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugElement.java | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugElement.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugElement.java new file mode 100644 index 000000000..53fd618f7 --- /dev/null +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugElement.java @@ -0,0 +1,135 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.core; + +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.debug.core.DebugEvent; +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.debug.core.model.IProcess; +import org.eclipse.debug.core.model.IStepFilters; + +/** + * Implementation of common function for debug elements. + * <p> + * Clients may subclass this class. + * TODO: in progress, make API + * </p> + * @since 3.1 + */ +public abstract class DebugElement extends PlatformObject implements IDebugElement { + + private IDebugTarget fTarget; + + /** + * Constructs a debug element referring to an artifact in the given + * debug target. + * + * @param target debug target containing this element + */ + public DebugElement(IDebugTarget target) { + fTarget = target; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget() + */ + public IDebugTarget getDebugTarget() { + return fTarget; + } + + /* (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(Class adapter) { + if (adapter == IDebugElement.class) { + return this; + } + if (adapter == IStepFilters.class) { + return getDebugTarget(); + } + if (adapter == IDebugTarget.class) { + return getDebugTarget(); + } + if (adapter == ILaunch.class) { + return getLaunch(); + } + if (adapter == IProcess.class) { + return getDebugTarget().getProcess(); + } + return super.getAdapter(adapter); + } + + /** + * Fires a debug event. + * + * @param event debug event to fire + */ + protected void fireEvent(DebugEvent event) { + DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {event}); + } + + /** + * Fires a change event for this debug element + * with the specified detail code. + * + * @param detail detail code for the change event, + * such as <code>DebugEvent.STATE</code> or <code>DebugEvent.CONTENT</code> + */ + public void fireChangeEvent(int detail) { + fireEvent(new DebugEvent(this, DebugEvent.CHANGE, detail)); + } + + /** + * Fires a creation event for this debug element. + */ + protected void fireCreationEvent() { + fireEvent(new DebugEvent(this, DebugEvent.CREATE)); + } + + /** + * Fires a resume for this debug element with + * the specified detail code. + * + * @param detail detail code for the resume event, such + * as <code>DebugEvent.STEP_OVER</code> + */ + protected void fireResumeEvent(int detail) { + fireEvent(new DebugEvent(this, DebugEvent.RESUME, detail)); + } + + /** + * Fires a suspend event for this debug element with + * the specified detail code. + * + * @param detail detail code for the suspend event, such + * as <code>DebugEvent.BREAKPOINT</code> + */ + protected void fireSuspendEvent(int detail) { + fireEvent(new DebugEvent(this, DebugEvent.SUSPEND, detail)); + } + + /** + * Fires a terminate event for this debug element. + */ + protected void fireTerminateEvent() { + fireEvent(new DebugEvent(this, DebugEvent.TERMINATE)); + } +} |