Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/AbstractDebugContextProvider.java')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/AbstractDebugContextProvider.java88
1 files changed, 88 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/AbstractDebugContextProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/AbstractDebugContextProvider.java
new file mode 100644
index 000000000..5370af0ad
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/AbstractDebugContextProvider.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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.internal.ui.contexts.provisional;
+
+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
+ */
+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 addDebugContextEventListener(IDebugContextEventListener 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 removeDebugContextEventListener(IDebugContextEventListener 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 IDebugContextEventListener listener = (IDebugContextEventListener) listeners[i];
+ SafeRunner.run(new ISafeRunnable() {
+ public void run() throws Exception {
+ listener.contextEvent(event);
+ }
+ public void handleException(Throwable exception) {
+ DebugUIPlugin.log(exception);
+ }
+ });
+
+ }
+ }
+}

Back to the top