Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java94
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/DebugContextEvent.java101
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextListener.java40
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextManager.java62
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextProvider.java78
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextService.java134
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/package.html18
7 files changed, 527 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java
new file mode 100644
index 000000000..5a5f6ab5a
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.ui.contexts;
+
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Abstract implementation of a debug context provider.
+ * <p>
+ * Clients implementing context providers should subclass this class.
+ * </p>
+ * @since 3.3
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * remain unchanged during the 3.3 release cycle. Please do not use this API
+ * without consulting with the Platform/Debug team.
+ * </p>
+ */
+public abstract class AbstractDebugContextProvider implements IDebugContextProvider {
+
+ /**
+ * Event listeners
+ */
+ private ListenerList fListeners = new ListenerList();
+
+ /**
+ * Part or <code>null</code>
+ */
+ private IWorkbenchPart fPart;
+
+ /**
+ * Constructs a context provider for the specified part, possibly <code>null</code>.
+ *
+ * @param part workbench part or <code>null</code>
+ */
+ public AbstractDebugContextProvider(IWorkbenchPart part) {
+ fPart = part;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextProvider#addDebugContextEventListener(org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextEventListener)
+ */
+ public void addDebugContextListener(IDebugContextListener listener) {
+ fListeners.add(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextProvider#getPart()
+ */
+ public IWorkbenchPart getPart() {
+ return fPart;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextProvider#removeDebugContextEventListener(org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextEventListener)
+ */
+ public void removeDebugContextListener(IDebugContextListener listener) {
+ fListeners.remove(listener);
+ }
+
+ /**
+ * Fires the given context event to all listeners.
+ *
+ * @param event debug context event
+ */
+ protected void fire(final DebugContextEvent event) {
+ Object[] listeners = fListeners.getListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ final IDebugContextListener listener = (IDebugContextListener) listeners[i];
+ SafeRunner.run(new ISafeRunnable() {
+ public void run() throws Exception {
+ listener.debugContextChanged(event);
+ }
+ public void handleException(Throwable exception) {
+ DebugUIPlugin.log(exception);
+ }
+ });
+
+ }
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/DebugContextEvent.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/DebugContextEvent.java
new file mode 100644
index 000000000..970c4afc8
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/DebugContextEvent.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.ui.contexts;
+
+import java.util.EventObject;
+
+import org.eclipse.jface.viewers.ISelection;
+
+/**
+ * A debug context event. Debug context events are generated by debug context
+ * providers. A debug context is represented by a selection and flags
+ * (bit mask) describing how the context has changed.
+ * <p>
+ * Clients may instantiate this class; not intended to be subclassed.
+ * </p>
+ * @see IDebugContextListener
+ * @see IDebugContextProvider
+ * @since 3.3
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * remain unchanged during the 3.3 release cycle. Please do not use this API
+ * without consulting with the Platform/Debug team.
+ * </p>
+ */
+public class DebugContextEvent extends EventObject {
+
+ /**
+ * The context
+ */
+ private ISelection fContext;
+
+ /**
+ * Change flags.
+ */
+ private int fFlags;
+
+ /**
+ * Change constant (bit mask) indicating a context has been activated.
+ */
+ public static final int ACTIVATED = 0x01;
+
+ /**
+ * Change constant (bit mask) indicating the state of a context has changed.
+ * State changes are only broadcast for previously activated contexts.
+ */
+ public static final int STATE = 0x10;
+
+ /**
+ * Generated serial version UID for this class.
+ */
+ private static final long serialVersionUID = 3395172504615255524L;
+
+ /**
+ * Constructs a new debug context event.
+ *
+ * @param source source of the event - a debug context provider
+ * @param context the relevant context
+ * @param flags bit mask indicating how the context has changed
+ */
+ public DebugContextEvent(IDebugContextProvider source, ISelection context, int flags) {
+ super(source);
+ fContext = context;
+ fFlags = flags;
+ }
+
+ /**
+ * Returns the debug context associated with this event.
+ *
+ * @return debug context, possible an empty selection
+ */
+ public ISelection getContext() {
+ return fContext;
+ }
+
+ /**
+ * Returns flags which describe in more detail how a context has changed.
+ *
+ * @return event flags
+ */
+ public int getFlags() {
+ return fFlags;
+ }
+
+ /**
+ * Returns the context provider that initiated this event.
+ *
+ * @return context provider
+ */
+ public IDebugContextProvider getDebugContextProvider() {
+ return (IDebugContextProvider) getSource();
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextListener.java
new file mode 100644
index 000000000..7135cee5d
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextListener.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.ui.contexts;
+
+
+/**
+ * A debug context listener is notified of debug context events.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * @see DebugContextEvent
+ * @see IDebugContextManager
+ * @see IDebugContextService
+ * @see IDebugContextProvider
+ * @since 3.3
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * remain unchanged during the 3.3 release cycle. Please do not use this API
+ * without consulting with the Platform/Debug team.
+ * </p>
+ */
+public interface IDebugContextListener {
+
+ /**
+ * Notification the debug context has changed as specified by the given event.
+ *
+ * @param event debug context event
+ */
+ public void debugContextChanged(DebugContextEvent event);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextManager.java
new file mode 100644
index 000000000..00ce964f3
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextManager.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.ui.contexts;
+
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * Manages debug context services. There is a debug context service
+ * for each workbench window. Clients interested in context change
+ * notification for all windows can register with the manager. Clients
+ * interested in context change notification for a specific window
+ * can register with the context service specific to that window.
+ * <p>
+ * Clients register debug context providers with a context service - i.e.
+ * for a specific window.
+ * </p>
+ * <p>
+ * Not intended to be implemented by clients.
+ * </p>
+ * @see IDebugContextProvider
+ * @see IDebugContextListener
+ * @see IDebugContextService
+ * @since 3.3
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * remain unchanged during the 3.3 release cycle. Please do not use this API
+ * without consulting with the Platform/Debug team.
+ * </p>
+ */
+public interface IDebugContextManager {
+
+ /**
+ * Registers the given listener for debug context notification in all windows.
+ *
+ * @param listener debug context listener
+ */
+ public void addDebugContextListener(IDebugContextListener listener);
+
+ /**
+ * Unregisters the given listener for context notification in all windows.
+ *
+ * @param listener debug context listener
+ */
+ public void removeDebugContextListener(IDebugContextListener listener);
+
+ /**
+ * Returns the debug context service for the specified window.
+ *
+ * @param window workbench window
+ * @return debug context service
+ */
+ public IDebugContextService getContextService(IWorkbenchWindow window);
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextProvider.java
new file mode 100644
index 000000000..c43a91f1c
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextProvider.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.ui.contexts;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Interface common to all objects that provide a debug context. A context provider
+ * is registered with a debug context service associated with a specific window.
+ * <p>
+ * A context provider can provide context information for a specific workbench part.
+ * There can only be one context provider registered per part with a context
+ * service. When there is more than one context provider per window, the context provider
+ * associated with the most recently active part provides the context for that window.
+ * </p>
+ * <p>
+ * A context provider does not have to be associated with a part. In this case the provider
+ * specifies <code>null</code> for its part, and provides context information for the window.
+ * There can only be one context provider without an associated part registered per context
+ * service (i.e. per window). A context provider that provides context without an associated
+ * part is only active (i.e. used to provide context information) when there are no other
+ * context providers with associated parts registered with that service.
+ * </p>
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * @see IDebugContextManager
+ * @see IDebugContextService
+ * @see IDebugContextEventListener
+ * @since 3.3
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * remain unchanged during the 3.3 release cycle. Please do not use this API
+ * without consulting with the Platform/Debug team.
+ * </p>
+ */
+public interface IDebugContextProvider {
+
+ /**
+ * Returns the part associated with this context provider or <code>null</code>
+ * if none.
+ *
+ * @return part associated with this context provider or <code>null</code>
+ */
+ public IWorkbenchPart getPart();
+
+ /**
+ * Registers the given listener for debug context events.
+ *
+ * @param listener event listener
+ */
+ public void addDebugContextListener(IDebugContextListener listener);
+
+ /**
+ * Unregisters the given listener for debug context events.
+ *
+ * @param listener event listener
+ */
+ public void removeDebugContextListener(IDebugContextListener listener);
+
+ /**
+ * Returns the currently active context, possibly empty or <code>null</code>.
+ *
+ * @return active context, possibly empty or <code>null</code>.
+ */
+ public ISelection getActiveContext();
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextService.java
new file mode 100644
index 000000000..7fc52b594
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/IDebugContextService.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.ui.contexts;
+
+import org.eclipse.jface.viewers.ISelection;
+
+
+/**
+ * Debug context service for a window. Clients may register for debug context
+ * notification with this service. A context service is obtained from the
+ * debug context manager.
+ * <p>
+ * Not intended to be implemented by clients.
+ * </p>
+ * @see IDebugContextManager
+ * @since 3.3
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * remain unchanged during the 3.3 release cycle. Please do not use this API
+ * without consulting with the Platform/Debug team.
+ * </p>
+ */
+public interface IDebugContextService {
+
+ /**
+ * Registers for the given listener for debug context change notification
+ * in this service's window.
+ *
+ * @param listener debug context listener
+ */
+ public void addDebugContextListener(IDebugContextListener listener);
+ /**
+ * Unregisters for the given listener for debug context change notification
+ * in this service's window.
+ *
+ * @param listener debug context listener
+ */
+ public void removeDebugContextListener(IDebugContextListener listener);
+
+ /**
+ * Registers for the given debug context listener for context notification
+ * from the specified part in this service's window.
+ *
+ * @param listener debug context listener
+ * @param partId part identifier
+ */
+ public void addDebugContextListener(IDebugContextListener listener, String partId);
+
+ /**
+ * Unregisters the given debug context listener for context change notification
+ * from the specified part in this service's window.
+ *
+ * @param listener debug context listener
+ * @param partId part identifier
+ */
+ public void removeDebugContextListener(IDebugContextListener listener, String partId);
+
+ /**
+ * Returns the active context in this service's window
+ * or <code>null</code>.
+ *
+ * @return active context or <code>null</code>
+ */
+ public ISelection getActiveContext();
+
+ /**
+ * Returns the active context in the specified part of this service's window
+ * or <code>null</code> if none.
+ *
+ * @param partId part identifier
+ * @return active context or <code>null</code>
+ */
+ public ISelection getActiveContext(String partId);
+
+ /**
+ * Registers the given debug context listener for post context change notification
+ * in this service's window. Post listeners are notified of context changes after all
+ * non-post listeners are notified.
+ *
+ * @param listener debug context listener
+ */
+ public void addPostDebugContextListener(IDebugContextListener listener);
+
+ /**
+ * Unregisters the given debug context listener for post context change notification
+ * in this service's window.
+ *
+ * @param listener debug context listener.
+ */
+ public void removePostDebugContextListener(IDebugContextListener listener);
+
+ /**
+ * Registers the given debug context listener for post context change notification
+ * in the specified part of this service's window. Post listeners are notified of
+ * context changes after all non-post listeners are notified.
+ *
+ * @param listener debug context listener
+ * @param partId part identifier
+ */
+ public void addPostDebugContextListener(IDebugContextListener listener, String partId);
+
+ /**
+ * Unregisters the given debug context listener for post context change notification
+ * in the specified part of this service's window.
+ *
+ * @param listener debug context listener
+ * @param partId part identifier
+ */
+ public void removePostDebugContextListener(IDebugContextListener listener, String partId);
+
+ /**
+ * Registers the given debug context provider with this service.
+ *
+ * @param provider debug context provider
+ */
+ public void addDebugContextProvider(IDebugContextProvider provider);
+
+ /**
+ * Unregisters the given debug context provider from this service.
+ *
+ * @param provider debug context provider
+ */
+ public void removeDebugContextProvider(IDebugContextProvider provider);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/package.html b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/package.html
new file mode 100644
index 000000000..f5bc35985
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/package.html
@@ -0,0 +1,18 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>Debug Contexts</title>
+</head>
+
+<body link="#0000FF" vlink="#800080">
+
+<p align="left">Provides a set of interfaces and classes for debug context management.</p>
+
+<h2 align="left">Package Specification</h2>
+
+<p>This package provides a set interfaces and classses for listening to and specifying
+ the active debug in each workbench window.</p>
+</body>
+</html>

Back to the top