Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Burns2004-04-27 16:07:26 +0000
committerJared Burns2004-04-27 16:07:26 +0000
commitb86142d73422c23c11bb68a67c08cc429f7f1222 (patch)
tree9ae0c019222e3cbc83d8a747e22a7b43debaf221 /org.eclipse.debug.ui/ui
parenta2d07ae3e1bf63017e8b4850d32ff6a98c06909c (diff)
downloadeclipse.platform.debug-b86142d73422c23c11bb68a67c08cc429f7f1222.tar.gz
eclipse.platform.debug-b86142d73422c23c11bb68a67c08cc429f7f1222.tar.xz
eclipse.platform.debug-b86142d73422c23c11bb68a67c08cc429f7f1222.zip
Bug 59990 - function keys not working
Diffstat (limited to 'org.eclipse.debug.ui/ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugContextManager.java131
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewContextListener.java70
3 files changed, 141 insertions, 62 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
index a2e74abfb..2244295e5 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
@@ -45,6 +45,7 @@ import org.eclipse.debug.core.IStatusHandler;
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.internal.ui.actions.DebugContextManager;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
import org.eclipse.debug.internal.ui.launchConfigurations.PerspectiveManager;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
@@ -700,6 +701,7 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener {
if (fStepFilterManager == null) {
getStepFilterManager().launchAdded(launch);
}
+ DebugContextManager.getDefault().launchesAdded(new ILaunch[] { launch });
getLaunchConfigurationManager().startup();
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugContextManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugContextManager.java
new file mode 100644
index 000000000..ce74ba5fc
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/DebugContextManager.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 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.ui.actions;
+
+import java.util.Collections;
+import java.util.List;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.contexts.EnabledSubmission;
+import org.eclipse.ui.contexts.IWorkbenchContextSupport;
+
+/**
+ * Manages the debug scope in response to active debug sessions.
+ * When something is being debugged, the scope is activated.
+ * When all debugging stops, the scope is deactivated.
+ *
+ * @since 3.0
+ */
+public class DebugContextManager implements ILaunchesListener2 {
+
+
+ public static final String DEBUG_SCOPE = "org.eclipse.debug.ui.debugging"; //$NON-NLS-1$
+
+ // whether the debug scope is currently on
+ private boolean fDebugging = false;
+
+ // debug scope submission
+ private List fDebugSubmission = Collections.singletonList(new EnabledSubmission((String) null, (Shell)null, (IWorkbenchPartSite)null, DEBUG_SCOPE));
+
+ // singleton
+ private static DebugContextManager contextServiceManager;
+
+ public static DebugContextManager getDefault() {
+ if (contextServiceManager == null) {
+ contextServiceManager = new DebugContextManager();
+ }
+ return contextServiceManager;
+ }
+
+ private DebugContextManager() {
+ DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
+ }
+
+ /**
+ * Returns whether the debug scope is currently on.
+ *
+ * @return whether the debug scope is currently on
+ */
+ public boolean isDebugging() {
+ return fDebugging;
+ }
+
+ /**
+ * Sets whether the debug scope is currently on.
+ *
+ * @param debugging whether the debug scope is currently on
+ */
+ private void setDebugging(boolean debugging) {
+ if (debugging != fDebugging) {
+ fDebugging = debugging;
+ DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchContextSupport contextSupport = PlatformUI.getWorkbench().getContextSupport();
+ if (fDebugging) {
+ contextSupport.addEnabledSubmissions(fDebugSubmission);
+ } else {
+ contextSupport.removeEnabledSubmissions(fDebugSubmission);
+ }
+ }
+ });
+
+ }
+ }
+
+ public synchronized void launchesAdded(ILaunch[] launches) {
+ for (int i = 0; i < launches.length; i++) {
+ if (launches[i].getLaunchMode().equals(ILaunchManager.DEBUG_MODE)) {
+ setDebugging(true);
+ return;
+ }
+ }
+ }
+
+ public void launchesRemoved(ILaunch[] launches) {
+ }
+
+ public void launchesChanged(ILaunch[] launches) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.core.ILaunchListener2#launchTerminated(org.eclipse.debug.core.ILaunch)
+ */
+ public synchronized void launchesTerminated(ILaunch[] launches) {
+ boolean debugLaunchTerminated = false;
+ for (int i = 0; i < launches.length; i++) {
+ if (launches[i].getLaunchMode().equals(ILaunchManager.DEBUG_MODE)) {
+ debugLaunchTerminated= true;
+ break;
+ }
+ }
+ if (debugLaunchTerminated) {
+ // if nothing left in debug mode, turn debugging off
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunch[] remainingLaunches = manager.getLaunches();
+ for (int i = 0; i < remainingLaunches.length; i++) {
+ ILaunch l = remainingLaunches[i];
+ if (ILaunchManager.DEBUG_MODE.equals(l.getLaunchMode()) && !l.isTerminated()) {
+ // still debugging
+ return;
+ }
+ }
+ setDebugging(false);
+ }
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewContextListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewContextListener.java
index 47df8698e..5fbfebbbe 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewContextListener.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewContextListener.java
@@ -26,6 +26,7 @@ import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IDebugModelProvider;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.actions.DebugContextManager;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPageListener;
import org.eclipse.ui.IPartListener2;
@@ -193,34 +194,6 @@ public class LaunchViewContextListener implements IPartListener2, IPageListener,
contextIds.add(contextId);
}
}
- // add parent contexts
- Iterator modelIds = modelsToContexts.keySet().iterator();
- IContextManager manager = PlatformUI.getWorkbench().getContextSupport().getContextManager();
- while (modelIds.hasNext()) {
- String modelId = (String) modelIds.next();
- List contexts = (List) modelsToContexts.get(modelId);
- Set allContexts = new HashSet(contexts.size());
- Iterator iterator = contexts.iterator();
- while (iterator.hasNext()) {
- String contextId = (String) iterator.next();
- IContext context = manager.getContext(contextId);
- while (context != null && context.isDefined()) {
- allContexts.add(contextId);
- try {
- contextId = context.getParentId();
- context = null;
- if (contextId != null) {
- context = manager.getContext(contextId);
- }
- } catch (NotDefinedException e) {
- context = null;
- }
- }
- }
- List list = new ArrayList(allContexts.size());
- list.addAll(allContexts);
- modelsToContexts.put(modelId, list);
- }
}
/**
@@ -400,6 +373,12 @@ public class LaunchViewContextListener implements IPartListener2, IPageListener,
*/
public void contextEnabled(Set contextIds) {
IWorkbenchPage page= getActiveWorkbenchPage();
+ // We ignore the "Debugging" context since we use it
+ // to provide a base set of views for other context
+ // bindings to inherit. If we don't ignore it, we'll
+ // end up opening those views whenever a debug session
+ // starts, which is not the desired behavior.
+ contextIds.remove(DebugContextManager.DEBUG_SCOPE);
if (page == null || contextIds.size() == 0) {
return;
}
@@ -457,7 +436,7 @@ public class LaunchViewContextListener implements IPartListener2, IPageListener,
if (page == null) {
return;
}
- Iterator contexts = getLeafContexts(contextIds).iterator();
+ Iterator contexts = contextIds.iterator();
while (contexts.hasNext()) {
String contextId = (String) contexts.next();
Iterator configurationElements= getConfigurationElements(contextId).iterator();
@@ -479,39 +458,6 @@ public class LaunchViewContextListener implements IPartListener2, IPageListener,
}
/**
- * Returns a set containing the leaf context ids in the givne
- * set. That is, any entry in the set which is a parent of an
- * entry in the set is removed.
- *
- * @param contextIds
- * @return
- */
- private Set getLeafContexts(Set contextIds) {
- Set leaves = new HashSet(contextIds.size());
- leaves.addAll(contextIds);
- Iterator contexts = contextIds.iterator();
- IContextManager manager = PlatformUI.getWorkbench().getContextSupport().getContextManager();
- while (contexts.hasNext()) {
- String contextId = (String) contexts.next();
- IContext context = manager.getContext(contextId);
- String parentId = null;
- try {
- parentId = context.getParentId();
- } catch (NotDefinedException e) {
- }
- while (parentId != null) {
- leaves.remove(parentId);
- try {
- parentId = manager.getContext(parentId).getParentId();
- } catch (NotDefinedException e1) {
- parentId = null;
- }
- }
- }
- return leaves;
- }
-
- /**
* The given contexts have been disabled. Close all views
* associated with these contexts that aren't associated
* with other active contexts.

Back to the top