From 4fe8f08266ae4b63ac800d5af4c1c274fba9e8d4 Mon Sep 17 00:00:00 2001 From: Darin Wright Date: Mon, 16 Oct 2006 18:47:27 +0000 Subject: Bug 160932 API for debug context and debug commands --- .../eclipse/debug/internal/ui/DebugUIPlugin.java | 2 +- .../debug/internal/ui/StepFilterManager.java | 12 +- .../debug/internal/ui/actions/ActionMessages.java | 2 + .../internal/ui/actions/ActionMessages.properties | 2 + .../context/AbstractDebugContextAction.java | 292 --------------------- .../AbstractDebugContextActionDelegate.java | 130 --------- .../ui/actions/context/AbstractRequestMonitor.java | 84 ------ .../ui/actions/context/ActionAdapterFactory.java | 95 ------- .../ui/actions/context/ActionRequestMonitor.java | 60 ----- .../context/BooleanOrWiseRequestMonitor.java | 52 ---- .../ui/actions/context/BooleanRequestMonitor.java | 57 ---- .../ui/actions/context/DisconnectAction.java | 133 ---------- .../actions/context/DisconnectActionDelegate.java | 19 -- .../ui/actions/context/DisconnectAdapter.java | 108 -------- .../ui/actions/context/DropToFrameAction.java | 114 -------- .../actions/context/DropToFrameActionDelegate.java | 19 -- .../ui/actions/context/DropToFrameAdapter.java | 81 ------ .../internal/ui/actions/context/ResumeAction.java | 172 ------------ .../ui/actions/context/ResumeActionDelegate.java | 18 -- .../ui/actions/context/StandardActionAdapter.java | 32 --- .../internal/ui/actions/context/StepAction.java | 43 --- .../internal/ui/actions/context/StepAdapter.java | 197 -------------- .../ui/actions/context/StepFiltersAdapter.java | 145 ---------- .../ui/actions/context/StepIntoAction.java | 128 --------- .../ui/actions/context/StepIntoActionDelegate.java | 21 -- .../ui/actions/context/StepOverAction.java | 128 --------- .../ui/actions/context/StepOverActionDelegate.java | 20 -- .../ui/actions/context/StepReturnAction.java | 86 ------ .../actions/context/StepReturnActionDelegate.java | 21 -- .../internal/ui/actions/context/SuspendAction.java | 89 ------- .../ui/actions/context/SuspendActionDelegate.java | 21 -- .../ui/actions/context/SuspendResumeAdapter.java | 142 ---------- .../ui/actions/context/TerminateAction.java | 83 ------ .../actions/context/TerminateActionDelegate.java | 22 -- .../ui/actions/context/TerminateAdapter.java | 138 ---------- .../ui/actions/context/TerminateAllAction.java | 140 ---------- .../context/TerminateAndRelaunchAction.java | 141 ---------- .../actions/context/TerminateAndRemoveAction.java | 108 -------- .../context/TerminateAndRemoveActionDelegate.java | 21 -- .../actions/context/ToggleStepFiltersAction.java | 114 -------- .../context/ToggleStepFiltersActionDelegate.java | 94 ------- .../IAsynchronousDisconnectAdapter.java | 45 ---- .../IAsynchronousDropToFrameAdapter.java | 37 --- .../provisional/IAsynchronousStepAdapter.java | 71 ----- .../IAsynchronousStepFiltersAdapter.java | 44 ---- .../IAsynchronousSuspendResumeAdapter.java | 58 ---- .../provisional/IAsynchronousTerminateAdapter.java | 45 ---- .../provisional/IBooleanRequestMonitor.java | 28 -- .../debug/internal/ui/commands/DebugCommand.java | 147 +++++++++++ .../internal/ui/commands/DisconnectCommand.java | 42 +++ .../internal/ui/commands/DropToFrameCommand.java | 42 +++ .../debug/internal/ui/commands/ResumeCommand.java | 33 +++ .../debug/internal/ui/commands/StepCommand.java | 31 +++ .../internal/ui/commands/StepFiltersCommand.java | 81 ++++++ .../internal/ui/commands/StepIntoCommand.java | 33 +++ .../internal/ui/commands/StepOverCommand.java | 33 +++ .../internal/ui/commands/StepReturnCommand.java | 33 +++ .../debug/internal/ui/commands/SuspendCommand.java | 42 +++ .../internal/ui/commands/TerminateCommand.java | 42 +++ .../commands/actions/AbstractRequestMonitor.java | 84 ++++++ .../ui/commands/actions/ActionAdapterFactory.java | 131 +++++++++ .../ui/commands/actions/ActionRequestMonitor.java | 60 +++++ .../ui/commands/actions/BooleanRequestMonitor.java | 57 ++++ .../ui/commands/actions/CommandMonitor.java | 42 +++ .../ui/commands/actions/DebugCommandAction.java | 269 +++++++++++++++++++ .../actions/DebugCommandActionDelegate.java | 126 +++++++++ .../ui/commands/actions/DebugCommandService.java | 205 +++++++++++++++ .../commands/actions/DisconnectCommandAction.java | 57 ++++ .../commands/actions/DropToFrameCommandAction.java | 57 ++++ .../actions/ProxyBooleanRequestMonitor.java | 86 ++++++ .../ui/commands/actions/ResumeCommandAction.java | 61 +++++ .../actions/ResumeCommandActionDelegate.java | 27 ++ .../ui/commands/actions/StepIntoCommandAction.java | 61 +++++ .../actions/StepIntoCommandActionDelegate.java | 27 ++ .../ui/commands/actions/StepOverCommandAction.java | 63 +++++ .../actions/StepOverCommandActionDelegate.java | 27 ++ .../commands/actions/StepReturnCommandAction.java | 63 +++++ .../actions/StepReturnCommandActionDelegate.java | 27 ++ .../ui/commands/actions/SuspendCommandAction.java | 58 ++++ .../actions/SuspendCommandActionDelegate.java | 27 ++ .../ui/commands/actions/TerminateAllAction.java | 123 +++++++++ .../actions/TerminateAndRelaunchAction.java | 111 ++++++++ .../commands/actions/TerminateAndRemoveAction.java | 94 +++++++ .../commands/actions/TerminateCommandAction.java | 61 +++++ .../actions/TerminateCommandActionDelegate.java | 27 ++ .../commands/actions/ToggleStepFiltersAction.java | 80 ++++++ .../ToggleStepFiltersCommandActionDelegate.java | 27 ++ .../provisional/IBooleanRequestMonitor.java | 28 ++ .../ui/commands/provisional/IDebugCommand.java | 39 +++ .../commands/provisional/IDisconnectCommand.java | 20 ++ .../commands/provisional/IDropToFrameCommand.java | 20 ++ .../ui/commands/provisional/IResumeCommand.java | 20 ++ .../commands/provisional/IStepFiltersCommand.java | 20 ++ .../ui/commands/provisional/IStepIntoCommand.java | 20 ++ .../ui/commands/provisional/IStepOverCommand.java | 20 ++ .../commands/provisional/IStepReturnCommand.java | 20 ++ .../ui/commands/provisional/ISuspendCommand.java | 20 ++ .../ui/commands/provisional/ITerminateCommand.java | 20 ++ .../internal/ui/contexts/DebugContextManager.java | 8 + .../ui/contexts/DebugWindowContextService.java | 81 ++++-- .../internal/ui/contexts/IDebugContextService.java | 69 ----- .../provisional/AbstractDebugContextProvider.java | 88 +++++++ .../ui/contexts/provisional/DebugContextEvent.java | 84 ++++++ .../provisional/IDebugContextEventListener.java | 31 +++ .../contexts/provisional/IDebugContextManager.java | 11 +- .../provisional/IDebugContextProvider.java | 12 +- .../contexts/provisional/IDebugContextService.java | 105 ++++++++ .../ui/viewers/AsynchronousRequestMonitor.java | 2 +- .../debug/internal/ui/views/launch/LaunchView.java | 205 ++++++--------- 109 files changed, 3415 insertions(+), 3939 deletions(-) delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractRequestMonitor.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ActionAdapterFactory.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ActionRequestMonitor.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/BooleanOrWiseRequestMonitor.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/BooleanRequestMonitor.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ResumeAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ResumeActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StandardActionAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepFiltersAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepIntoAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepIntoActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepOverAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepOverActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepReturnAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepReturnActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/SuspendAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/SuspendActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/SuspendResumeAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAllAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRelaunchAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRemoveAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRemoveActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ToggleStepFiltersAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ToggleStepFiltersActionDelegate.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousDisconnectAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousDropToFrameAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousStepAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousStepFiltersAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousSuspendResumeAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousTerminateAdapter.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IBooleanRequestMonitor.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DebugCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DropToFrameCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/ResumeCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepFiltersCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepIntoCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepOverCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepReturnCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/SuspendCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/TerminateCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/AbstractRequestMonitor.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionAdapterFactory.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionRequestMonitor.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/BooleanRequestMonitor.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/CommandMonitor.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DisconnectCommandAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DropToFrameCommandAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ProxyBooleanRequestMonitor.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandActionDelegate.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandActionDelegate.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandActionDelegate.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandActionDelegate.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandActionDelegate.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersAction.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersCommandActionDelegate.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IBooleanRequestMonitor.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDebugCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDisconnectCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDropToFrameCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IResumeCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepFiltersCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepIntoCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepOverCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepReturnCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/ISuspendCommand.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/ITerminateCommand.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/IDebugContextService.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/AbstractDebugContextProvider.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/DebugContextEvent.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextEventListener.java create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextService.java (limited to 'org.eclipse.debug.ui/ui/org') 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 0d72bf67a..1e574c4c7 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 @@ -69,7 +69,7 @@ import org.eclipse.debug.core.model.ISuspendResume; import org.eclipse.debug.core.model.ITerminate; import org.eclipse.debug.core.model.IThread; import org.eclipse.debug.core.model.IVariable; -import org.eclipse.debug.internal.ui.actions.context.ActionAdapterFactory; +import org.eclipse.debug.internal.ui.commands.actions.ActionAdapterFactory; import org.eclipse.debug.internal.ui.contexts.SuspendTriggerAdapterFactory; import org.eclipse.debug.internal.ui.launchConfigurations.ClosedProjectFilter; import org.eclipse.debug.internal.ui.launchConfigurations.DeletedProjectFilter; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/StepFilterManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/StepFilterManager.java index e8b8a0b03..b599e1ad4 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/StepFilterManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/StepFilterManager.java @@ -13,8 +13,8 @@ package org.eclipse.debug.internal.ui; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchListener; -import org.eclipse.debug.internal.ui.actions.context.ActionRequestMonitor; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepFiltersAdapter; +import org.eclipse.debug.internal.ui.commands.actions.ActionRequestMonitor; +import org.eclipse.debug.internal.ui.commands.provisional.IStepFiltersCommand; /** * As targets are launched, this manager sets its step filter @@ -49,11 +49,9 @@ public class StepFilterManager implements ILaunchListener { * @see org.eclipse.debug.core.ILaunchListener#launchChanged(org.eclipse.debug.core.ILaunch) */ public void launchChanged(ILaunch launch) { - boolean useStepFilters = isUseStepFilters(); - IAsynchronousStepFiltersAdapter stepFilterAdapter = (IAsynchronousStepFiltersAdapter)launch.getAdapter(IAsynchronousStepFiltersAdapter.class); - if (stepFilterAdapter != null) - { - stepFilterAdapter.setStepFiltersEnabled(launch, useStepFilters, new ActionRequestMonitor()); + IStepFiltersCommand command = (IStepFiltersCommand)launch.getAdapter(IStepFiltersCommand.class); + if (command != null) { + command.execute(launch, new ActionRequestMonitor()); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java index a48bc3d6f..03d8aa257 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java @@ -112,6 +112,8 @@ public class ActionMessages extends NLS { public static String ToggleBreakpointAction_1; public static String ToggleBreakpointAction_2; + public static String ToggleStepFiltersAction_0; + public static String WatchExpressionDialog_0; public static String WatchExpressionDialog_1; public static String WatchExpressionDialog_2; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties index bd894fac3..15ae76a7a 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties @@ -123,6 +123,8 @@ ToggleBreakpointAction_0=Toggle Brea&kpoint ToggleBreakpointAction_1=Error ToggleBreakpointAction_2=Unable to toggle breakpoint +ToggleStepFiltersAction_0=Toggle Step Filters + WatchExpressionDialog_0=Edit Watch Expression WatchExpressionDialog_1=Add Watch Expression WatchExpressionDialog_2=E&xpression: diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextAction.java deleted file mode 100644 index dd9f6eeb4..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextAction.java +++ /dev/null @@ -1,292 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import java.util.Iterator; - -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.debug.internal.ui.contexts.DebugContextManager; -import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener; -import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextManager; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * Provides an abstract base class for asynchronous debug actions - * - * @since 3.2 - */ -public abstract class AbstractDebugContextAction extends Action implements IDebugContextListener { - - private IStructuredSelection fActiveContext; - private IWorkbenchWindow fWindow; - private AbstractDebugContextActionDelegate fDelegate; - - /** - * Constructor - */ - public AbstractDebugContextAction() { - super(); - String helpContextId = getHelpContextId(); - if (helpContextId != null) - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, helpContextId); - setEnabled(false); - } - - /** - * Set the current delegate - * @param delegate - */ - public void setDelegate(AbstractDebugContextActionDelegate delegate) { - fDelegate = delegate; - } - - /** - * This method is analagous to the standard 'run' method for an IAction - * @param target the target to perform the action on - */ - protected abstract void doAction(Object target); - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener#contextActivated(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart) - */ - public void contextActivated(ISelection context, IWorkbenchPart part) { - fActiveContext = null; - update(context); - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener#contextChanged(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart) - */ - public void contextChanged(ISelection context, IWorkbenchPart part) { - contextActivated(context, part); - } - - /** - * Updates the enabled state for the current selection - * @param context the current context to evaluate enablement with - */ - protected void update(ISelection context) { - if (context instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) context; - updateEnableStateForContext(ss); - fActiveContext = (IStructuredSelection) context; - } else { - setEnabled(false); - fActiveContext = StructuredSelection.EMPTY; - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.Action#setEnabled(boolean) - */ - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - if (fDelegate != null) { - fDelegate.setEnabled(enabled); - } - } - - /** - * Return whether the action should be enabled or not based on the given - * selection. - * This method uses the default BooleanRequestMonitor, which collects - * votes, and if not cancelled, sets enablement based on the equality of the number of voters - * to the total number of voters who could have voted - */ - protected void updateEnableStateForContext(IStructuredSelection selection) { - int size = selection.size(); - BooleanRequestMonitor monitor = new BooleanRequestMonitor(this, size); - if (size > 0) { - Iterator itr = selection.iterator(); - while (itr.hasNext()) { - Object element = itr.next(); - isEnabledFor(element, monitor); - } - } else { - notSupported(monitor); - } - } - - /** - * Calls back to the IBooleanRequestMonitor indicating if the action - * should be enabled based on the selected element - * @param element the element to determine enablement for - * @param monitor the IBooleanRequestMonitor to call back to - */ - protected abstract void isEnabledFor(Object element, IBooleanRequestMonitor monitor); - - /** - * Updates the monitor with a false result. Action should call this method when - * updating enablement and the function is not supported. - * - * @param monitor - */ - protected void notSupported(IBooleanRequestMonitor monitor) { - monitor.setResult(false); - monitor.done(); - } - - /** - * Initializes the context action - * @param window the window - */ - public void init(IWorkbenchWindow window) { - setWindow(window); - IDebugContextManager manager = DebugContextManager.getDefault(); - manager.addDebugContextListener(this, window); - ISelection activeContext = manager.getActiveContext(window); - if (activeContext != null) { - contextActivated(activeContext, null); - } else { - setEnabled(getInitialEnablement()); - } - } - - /** - * Returns whether this action should be enabled when initialized - * and there is no active debug context. - * - * @return false, by default - */ - protected boolean getInitialEnablement() { - return false; - } - - /** - * Set the window this action is contained within - * @param window the new window - */ - protected void setWindow(IWorkbenchWindow window) { - fWindow = window; - } - - /** - * Returns the most recent selection - * - * @return structured selection - */ - protected IStructuredSelection getContext() { - return fActiveContext; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.Action#run() - */ - public void run() { - IStructuredSelection selection = getContext(); - if (selection != null && isEnabled()) { - // disable the action so it cannot be run again until an event or - // selection change updates the enablement - setEnabled(false); - for (Iterator iter = selection.iterator(); iter.hasNext();) { - Object element = iter.next(); - doAction(element); - } - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event) - */ - public void runWithEvent(Event event) { - run(); - } - - /** - * Clean up when removing - */ - public void dispose() { - IWorkbenchWindow window = getWindow(); - if (getWindow() != null) { - DebugContextManager.getDefault().removeDebugContextListener(this, window); - } - } - - /** - * @return The current window this action is associated with - */ - protected IWorkbenchWindow getWindow() { - return fWindow; - } - - /** - * Returns the String to use as an error dialog message for a failed action. - * This message appears as the "Message:" in the error dialog for this - * action. Default is to return null. - */ - protected String getErrorDialogMessage() { - return null; - } - - /** - * Returns the String to use as a status message for a failed action. This - * message appears as the "Reason:" in the error dialog for this action. - * Default is to return the empty String. - */ - protected String getStatusMessage() { - return ""; //$NON-NLS-1$ - } - - /** - * @return The help context id for this action - */ - public abstract String getHelpContextId(); - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.Action#getId() - */ - public abstract String getId(); - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.Action#getText() - */ - public abstract String getText(); - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.Action#getToolTipText() - */ - public abstract String getToolTipText(); - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor() - */ - public abstract ImageDescriptor getDisabledImageDescriptor(); - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.Action#getHoverImageDescriptor() - */ - public abstract ImageDescriptor getHoverImageDescriptor(); - - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.Action#getImageDescriptor() - */ - public abstract ImageDescriptor getImageDescriptor(); -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextActionDelegate.java deleted file mode 100644 index dc672b476..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractDebugContextActionDelegate.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.actions.context; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IActionDelegate2; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -public abstract class AbstractDebugContextActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 { - - /** - *The real action for this delegate - */ - private AbstractDebugContextAction fDebugAction; - - /** - * The underlying action for this delegate - */ - private IAction fWindowAction; - - /** - * Whether this action has been initialized before it has been run - * (ensures enablement state is up to date when lazily instantiated) - */ - private boolean fInitialized = false; - - public AbstractDebugContextActionDelegate() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() - */ - public void dispose() { - fDebugAction.dispose(); - - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) - */ - public void init(IAction action) { - fWindowAction = action; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) - */ - public void init(IWorkbenchWindow window) { - setWindow(window); - fDebugAction.init(window); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public synchronized void run(IAction action) { - if (!fInitialized) { - try { - wait(); - } catch (InterruptedException e) { - } - } - fDebugAction.run(); - } - - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) - */ - public void runWithEvent(IAction action, Event event) { - run(action); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection s) { - // do nothing - } - - protected AbstractDebugContextAction getAction() { - return fDebugAction; - } - - protected void setAction(AbstractDebugContextAction action) { - fDebugAction = action; - action.setDelegate(this); - } - - protected IWorkbenchWindow getWindow() { - return fDebugAction.getWindow(); - } - - protected void setWindow(IWorkbenchWindow window) { - fDebugAction.setWindow(window); - } - - public synchronized void setEnabled(boolean enabled) { - if (!fInitialized) { - fInitialized = true; - notifyAll(); - } - fWindowAction.setEnabled(enabled); - } - - protected IAction getWindowAction() - { - return fWindowAction; - } - - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractRequestMonitor.java deleted file mode 100644 index 09da27eba..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/AbstractRequestMonitor.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; - -/** - * Common function for request monitors - * - * @since 3.2 - * - */ -public abstract class AbstractRequestMonitor implements IAsynchronousRequestMonitor { - - private IStatus fStatus; - private boolean fCancelled = false; - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor#setStatus(org.eclipse.core.runtime.IStatus) - */ - public void setStatus(IStatus status) { - fStatus = status; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int) - */ - public void beginTask(String name, int totalWork) { - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double) - */ - public void internalWorked(double work) { - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled() - */ - public boolean isCanceled() { - return fCancelled; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean) - */ - public void setCanceled(boolean value) { - fCancelled = value; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String) - */ - public void setTaskName(String name) { - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String) - */ - public void subTask(String name) { - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#worked(int) - */ - public void worked(int work) { - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor#getStatus() - */ - public IStatus getStatus() { - return fStatus; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ActionAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ActionAdapterFactory.java deleted file mode 100644 index 46a35494e..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ActionAdapterFactory.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.core.model.IDisconnect; -import org.eclipse.debug.core.model.IDropToFrame; -import org.eclipse.debug.core.model.IProcess; -import org.eclipse.debug.core.model.IStep; -import org.eclipse.debug.core.model.ISuspendResume; -import org.eclipse.debug.core.model.ITerminate; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDisconnectAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDropToFrameAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepFiltersAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousSuspendResumeAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousTerminateAdapter; - -/** - * Adapter factory for debug capabilities. - * - * @since 3.2 - * - */ -public class ActionAdapterFactory implements IAdapterFactory { - - private static IAsynchronousDisconnectAdapter fgDisconnectAdapter = new DisconnectAdapter(); - private static IAsynchronousDropToFrameAdapter fgDropToFrameAdapter = new DropToFrameAdapter(); - private static IAsynchronousStepAdapter fgStepAdapter = new StepAdapter(); - private static IAsynchronousStepFiltersAdapter fgStepFiltersAdapter = new StepFiltersAdapter(); - private static IAsynchronousSuspendResumeAdapter fgSuspendResumeAdapter = new SuspendResumeAdapter(); - private static IAsynchronousTerminateAdapter fgTerminateAdapter = new TerminateAdapter(); - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - if (IAsynchronousDisconnectAdapter.class.equals(adapterType)) { - if (adaptableObject instanceof IDisconnect) { - return fgDisconnectAdapter; - } - } - if (IAsynchronousDropToFrameAdapter.class.equals(adapterType)) { - if (adaptableObject instanceof IDropToFrame) { - return fgDropToFrameAdapter; - } - } - if (IAsynchronousStepAdapter.class.equals(adapterType)) { - if (adaptableObject instanceof IStep) { - return fgStepAdapter; - } - } - if (IAsynchronousStepFiltersAdapter.class.equals(adapterType)) { - if (adaptableObject instanceof IDebugElement || - adaptableObject instanceof ILaunch || - adaptableObject instanceof IProcess) { - return fgStepFiltersAdapter; - } - } - if (IAsynchronousSuspendResumeAdapter.class.equals(adapterType)) { - if (adaptableObject instanceof ISuspendResume) { - return fgSuspendResumeAdapter; - } - } - if (IAsynchronousTerminateAdapter.class.equals(adapterType)) { - if (adaptableObject instanceof ITerminate) { - return fgTerminateAdapter; - } - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { - return new Class[]{IAsynchronousDisconnectAdapter.class, - IAsynchronousDropToFrameAdapter.class, - IAsynchronousStepAdapter.class, - IAsynchronousStepFiltersAdapter.class, - IAsynchronousSuspendResumeAdapter.class, - IAsynchronousTerminateAdapter.class}; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ActionRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ActionRequestMonitor.java deleted file mode 100644 index fb23d53f8..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ActionRequestMonitor.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.internal.ui.DebugUIMessages; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.jface.dialogs.MessageDialog; - -/** - * Plain request monitor for actions. Has no result. - * - * @since 3.2 - * - */ -public class ActionRequestMonitor extends AbstractRequestMonitor { - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IProgressMonitor#done() - */ - public void done() { - final IStatus status = getStatus(); - if (status != null) { - switch (status.getSeverity()) { - case IStatus.ERROR: - DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - MessageDialog.openError(DebugUIPlugin.getShell(), DebugUIMessages.DebugUITools_Error_1, status.getMessage()); - } - }); - break; - case IStatus.WARNING: - DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - MessageDialog.openWarning(DebugUIPlugin.getShell(), DebugUIMessages.DebugUITools_Error_1, status.getMessage()); - } - }); - break; - case IStatus.INFO: - DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - MessageDialog.openInformation(DebugUIPlugin.getShell(), DebugUIMessages.DebugUITools_Error_1, status.getMessage()); - } - }); - break; - } - } - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/BooleanOrWiseRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/BooleanOrWiseRequestMonitor.java deleted file mode 100644 index ee1403662..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/BooleanOrWiseRequestMonitor.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.jface.action.IAction; - -/** - * Boolean Request monitor that collects votes from a number of voters. - * All participants vote, as each votes the results are or'd together, allowing - * for the pattern: if at least one of... - * - * @since 3.3 - */ -public class BooleanOrWiseRequestMonitor extends AbstractRequestMonitor implements IBooleanRequestMonitor { - - private boolean fResult = false; - private IAction fAction = null; - - /** - * Constructor - * @param action the action to set enabled state for after voting completes - */ - public BooleanOrWiseRequestMonitor(IAction action) { - fAction = action; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor#setResult(boolean) - */ - public void setResult(boolean result) { - fResult |= result; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#done() - */ - public void done() { - if(fAction != null) { - fAction.setEnabled(fResult); - } - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/BooleanRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/BooleanRequestMonitor.java deleted file mode 100644 index 4823ed59e..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/BooleanRequestMonitor.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.jface.action.IAction; - -/** - * Boolean request monitor that collects boolean results from a number of voters. - * Request is cancelled when one voter votes false. - * - * @since 3.2 - * - */ -public class BooleanRequestMonitor extends AbstractRequestMonitor implements IBooleanRequestMonitor { - - private IAction fAction; - private int fNumVoters; - private int fNumOfVotes = 0; - - BooleanRequestMonitor(IAction action, int numVoters) { - fAction = action; - fNumVoters = numVoters; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor#setResult(boolean) - */ - public void setResult(boolean result) { - fNumOfVotes++; - if (!isCanceled()) { - if (!result) { - setCanceled(true); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IProgressMonitor#done() - */ - public void done() { - if (isCanceled()) { - fAction.setEnabled(false); - } else { - fAction.setEnabled(fNumOfVotes == fNumVoters); - } - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectAction.java deleted file mode 100644 index 29b7174d0..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectAction.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.internal.ui.DebugPluginImages; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.actions.ActionMessages; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDisconnectAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.resource.ImageDescriptor; - -public class DisconnectAction extends AbstractDebugContextAction { - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#doAction(java.lang.Object) - */ - protected void doAction(Object element) { - if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; - IAsynchronousDisconnectAdapter disconnect = (IAsynchronousDisconnectAdapter) adaptable.getAdapter(IAsynchronousDisconnectAdapter.class); - if (disconnect != null) - disconnect.disconnect(element, new ActionRequestMonitor()); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#isEnabledFor(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - protected void isEnabledFor(Object element, IBooleanRequestMonitor monitor) { - if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; - IAsynchronousDisconnectAdapter disconnect = (IAsynchronousDisconnectAdapter) adaptable.getAdapter(IAsynchronousDisconnectAdapter.class); - if (disconnect != null) { - disconnect.canDisconnect(element, monitor); - } else { - notSupported(monitor); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getStatusMessage() - */ - protected String getStatusMessage() { - return ActionMessages.DisconnectActionDelegate_Exceptions_occurred_attempting_to_disconnect__2; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getErrorDialogMessage() - */ - protected String getErrorDialogMessage() { - return ActionMessages.DisconnectActionDelegate_Disconnect_failed_1; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getText() - */ - public String getText() { - return ActionMessages.DisconnectAction_0; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHelpContextId() - */ - public String getHelpContextId() { - return "disconnect_action_context"; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getId() - */ - public String getId() { - return "org.eclipse.debug.ui.debugview.toolbar.disconnect"; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getToolTipText() - */ - public String getToolTipText() { - return ActionMessages.DisconnectAction_3; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getDisabledImageDescriptor() - */ - public ImageDescriptor getDisabledImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_DISCONNECT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHoverImageDescriptor() - */ - public ImageDescriptor getHoverImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_DISCONNECT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_DISCONNECT); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectActionDelegate.java deleted file mode 100644 index 088d9ddde..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectActionDelegate.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.actions.context; - -public class DisconnectActionDelegate extends AbstractDebugContextActionDelegate { - public DisconnectActionDelegate() { - super(); - setAction(new DisconnectAction()); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectAdapter.java deleted file mode 100644 index 5ea371e3b..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DisconnectAdapter.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.model.IDisconnect; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDisconnectAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * Default disconnect adapter for standard debug model. - * - * @since 3.2 - */ -public class DisconnectAdapter extends StandardActionAdapter implements IAsynchronousDisconnectAdapter { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDisconnectAdapter#canDisconnect(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - public void canDisconnect(final Object element, final IBooleanRequestMonitor requestMonitor) { - Job job = new Job("canDisconnect") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - IDisconnect disconnect = getTarget(element); - if (disconnect != null) - requestMonitor.setResult(disconnect.canDisconnect()); - else - requestMonitor.setResult(false); - requestMonitor.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(createUpdateSchedulingRule()); - job.schedule(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDisconnectAdapter#isDisconnected(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - public void isDisconnected(final Object element, final IBooleanRequestMonitor requestMonitor) { - Job job = new Job("isDisconnected") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - IDisconnect disconnect = getTarget(element); - if (disconnect != null) { - requestMonitor.setResult(disconnect.isDisconnected()); - } else { - requestMonitor.setResult(false); - } - requestMonitor.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(createUpdateSchedulingRule()); - job.schedule(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDisconnectAdapter#disconnect(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor) - */ - public void disconnect(final Object element, final IAsynchronousRequestMonitor requestMonitor) { - Job job = new Job("isDisconnected") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - IDisconnect disconnect = getTarget(element); - - if (disconnect == null) { - requestMonitor.setStatus(new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.INTERNAL_ERROR, "element must be an instance of or adapt to IDisconnect", //$NON-NLS-1$ - null)); - } else { - try { - disconnect.disconnect(); - } catch (DebugException e) { - requestMonitor.setStatus(e.getStatus()); - } - } - requestMonitor.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); - } - - private IDisconnect getTarget(Object element) { - if (element instanceof IDisconnect) { - return (IDisconnect) element; - } else if (element instanceof IAdaptable) { - return (IDisconnect) ((IAdaptable) element).getAdapter(IDisconnect.class); - } - return null; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameAction.java deleted file mode 100644 index 62ec99a20..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameAction.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * 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.internal.ui.actions.context; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.internal.ui.DebugPluginImages; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.actions.ActionMessages; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDropToFrameAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * Action delegate which performs a drop to frame. - */ -public class DropToFrameAction extends AbstractDebugContextAction { - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#doAction(java.lang.Object) - */ - protected void doAction(Object element) { - if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; - IAsynchronousDropToFrameAdapter dropper = (IAsynchronousDropToFrameAdapter) adaptable.getAdapter(IAsynchronousDropToFrameAdapter.class); - if (dropper != null) - dropper.dropToFrame(element, new ActionRequestMonitor()); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#isEnabledFor(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - protected void isEnabledFor(Object element, IBooleanRequestMonitor monitor) { - if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; - IAsynchronousDropToFrameAdapter dropper = (IAsynchronousDropToFrameAdapter) adaptable.getAdapter(IAsynchronousDropToFrameAdapter.class); - if (dropper != null) { - dropper.canDropToFrame(element, monitor); - } else { - notSupported(monitor); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getText() - */ - public String getText() { - return ActionMessages.DropToFrameAction_0; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHelpContextId() - */ - public String getHelpContextId() { - return "drop_to_frame_action_context"; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getId() - */ - public String getId() { - return "org.eclipse.debug.ui.debugview.toolbar.dropToFrame"; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getToolTipText() - */ - public String getToolTipText() { - return ActionMessages.DropToFrameAction_3; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHoverImageDescriptor() - */ - public ImageDescriptor getHoverImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DROP_TO_FRAME); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DROP_TO_FRAME); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getDisabledImageDescriptor() - */ - public ImageDescriptor getDisabledImageDescriptor() { - return null; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameActionDelegate.java deleted file mode 100644 index 974fbf921..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameActionDelegate.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * 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.internal.ui.actions.context; - -public class DropToFrameActionDelegate extends AbstractDebugContextActionDelegate { - public DropToFrameActionDelegate() { - super(); - setAction(new DropToFrameAction()); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameAdapter.java deleted file mode 100644 index 69fdded8f..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/DropToFrameAdapter.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.model.IDropToFrame; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousDropToFrameAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; -import org.eclipse.debug.ui.IDebugUIConstants; - -public class DropToFrameAdapter extends StandardActionAdapter implements IAsynchronousDropToFrameAdapter { - - public void canDropToFrame(final Object element, final IBooleanRequestMonitor monitor) { - Job job = new Job("canDropToFrame") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor pm) { - if (!pm.isCanceled()) { - IDropToFrame dropToFrame = getTarget(element); - if (dropToFrame != null) { - monitor.setResult(dropToFrame.canDropToFrame()); - } else { - monitor.setResult(false); - } - monitor.done(); - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(createUpdateSchedulingRule()); - job.schedule(); - } - - public void dropToFrame(final Object element, final IAsynchronousRequestMonitor monitor) { - Job job = new Job("dropToFrame") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor pm) { - if (!pm.isCanceled()) { - IDropToFrame dropToFrame = getTarget(element); - if (dropToFrame != null) { - try { - dropToFrame.dropToFrame(); - } catch (DebugException e) { - monitor.setStatus(e.getStatus()); - } - } else { - monitor.setStatus(new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.INTERNAL_ERROR, "element must be an instance of or adapt to IDropToFrame", //$NON-NLS-1$ - null)); - } - monitor.done(); - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); - } - - private IDropToFrame getTarget(Object element) { - if (element instanceof IDropToFrame) { - return (IDropToFrame) element; - } else if (element instanceof IAdaptable) { - return (IDropToFrame) ((IAdaptable) element).getAdapter(IDropToFrame.class); - } - return null; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ResumeAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ResumeAction.java deleted file mode 100644 index 9477b72c1..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ResumeAction.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.core.model.IThread; -import org.eclipse.debug.internal.ui.DebugPluginImages; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.actions.ActionMessages; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousSuspendResumeAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.jface.resource.ImageDescriptor; - -public class ResumeAction extends AbstractDebugContextAction { - - public ResumeAction() { - setActionDefinitionId("org.eclipse.debug.ui.commands.Resume"); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#doAction(java.lang.Object) - */ - protected void doAction(Object element) { - if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; - IAsynchronousSuspendResumeAdapter suspendResumer = (IAsynchronousSuspendResumeAdapter) adaptable.getAdapter(IAsynchronousSuspendResumeAdapter.class); - if (suspendResumer != null) - suspendResumer.resume(element, new ActionRequestMonitor()); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#isEnabledFor(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - protected void isEnabledFor(Object element, IBooleanRequestMonitor monitor) { - if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; - IAsynchronousSuspendResumeAdapter suspendResumer = (IAsynchronousSuspendResumeAdapter) adaptable.getAdapter(IAsynchronousSuspendResumeAdapter.class); - if (suspendResumer != null) { - suspendResumer.canResume(element, monitor); - } else { - notSupported(monitor); - } - } - } - - - /** - * Resumes all threads in the target associated with the given element - * - * @param object - * debug element - * @throws DebugException - * on failure - */ - protected void doActionForAllThreads(Object object) throws DebugException { - if (isEnabledForAllThreads(object)) { - IDebugElement debugElement = (IDebugElement) object; - IThread[] threads = debugElement.getDebugTarget().getThreads(); - for (int i = 0; i < threads.length; i++) { - IThread thread = threads[i]; - if (thread.canResume()) { - thread.resume(); - } - } - } - } - - /** - * Returns whether 'resume all threads' should be enabled for the given - * element. - */ - protected boolean isEnabledForAllThreads(Object element) { - if (element instanceof IDebugElement) { - IDebugElement debugElement = (IDebugElement) element; - try { - IThread[] threads = debugElement.getDebugTarget().getThreads(); - for (int i = 0; i < threads.length; i++) { - if (threads[i].canResume()) { - return true; - } - } - } catch (DebugException e) { - } - } - return false; - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getStatusMessage() - */ - protected String getStatusMessage() { - return ActionMessages.ResumeActionDelegate_Exceptions_occurred_attempting_to_resume__2; - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getErrorDialogMessage() - */ - protected String getErrorDialogMessage() { - return ActionMessages.ResumeActionDelegate_Resume_failed__1; - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getText() - */ - public String getText() { - return ActionMessages.ResumeAction_0; - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHelpContextId() - */ - public String getHelpContextId() { - return "resume_action_context"; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getId() - */ - public String getId() { - return "org.eclipse.debug.ui.debugview.toolbar.resume"; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getToolTipText() - */ - public String getToolTipText() { - return ActionMessages.ResumeAction_3; - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getDisabledImageDescriptor() - */ - public ImageDescriptor getDisabledImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_RESUME); - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHoverImageDescriptor() - */ - public ImageDescriptor getHoverImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESUME); - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESUME); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ResumeActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ResumeActionDelegate.java deleted file mode 100644 index 447ede46e..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ResumeActionDelegate.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.actions.context; - -public class ResumeActionDelegate extends AbstractDebugContextActionDelegate { - public ResumeActionDelegate() { - super(); - setAction(new ResumeAction()); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StandardActionAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StandardActionAdapter.java deleted file mode 100644 index 19dc6d5f7..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StandardActionAdapter.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.debug.internal.ui.viewers.AsynchronousSchedulingRuleFactory; - -/** - * Common function for standard debug action adapter implemetnations. - * - * @since 3.2 - * - */ -public class StandardActionAdapter { - - /** - * Scheduling rule for updating action enablement. - * - * @return scheduling rule or null - */ - protected ISchedulingRule createUpdateSchedulingRule() { - return AsynchronousSchedulingRuleFactory.getDefault().newSerialRule(); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepAction.java deleted file mode 100644 index fe8d52f88..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepAction.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * 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 - * Pawel Piech - bug 134177 - *******************************************************************************/ - -package org.eclipse.debug.internal.ui.actions.context; - -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; - -public abstract class StepAction extends AbstractDebugContextAction { - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#doAction(java.lang.Object) - */ - protected void doAction(Object object) { - stepAction(object); - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#isEnabledFor(java.lang.Object) - */ - protected void isEnabledFor(Object element, IBooleanRequestMonitor monitor) { - checkCapability(element, monitor); - } - - - protected abstract void checkCapability(Object element, IBooleanRequestMonitor monitor); - /** - * Performs the specific step action. - * - * @exception DebugException if the action fails - */ - protected abstract void stepAction(Object element); -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepAdapter.java deleted file mode 100644 index 2c049c2b7..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepAdapter.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.model.IStep; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; -import org.eclipse.debug.ui.IDebugUIConstants; - -/** - * Default step adapter for standard debug model. - * - * @since 3.2 - */ -public class StepAdapter extends StandardActionAdapter implements IAsynchronousStepAdapter { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepAdapter#canStepInto(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - public void canStepInto(final Object element, final IBooleanRequestMonitor requestMonitor) { - Job job = new Job("canStepInto") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - IStep step = getTarget(element); - if (step != null) - requestMonitor.setResult(step.canStepInto()); - else - requestMonitor.setResult(false); - requestMonitor.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(createUpdateSchedulingRule()); - job.schedule(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepAdapter#canStepOver(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - public void canStepOver(final Object element, final IBooleanRequestMonitor requestMonitor) { - Job job = new Job("canStepOver") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - IStep step = getTarget(element); - if (step != null) - requestMonitor.setResult(step.canStepOver()); - else - requestMonitor.setResult(false); - requestMonitor.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(createUpdateSchedulingRule()); - job.schedule(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepAdapter#canStepReturn(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - public void canStepReturn(final Object element, final IBooleanRequestMonitor requestMonitor) { - Job job = new Job("canStepReturn") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - IStep step = getTarget(element); - if (step != null) - requestMonitor.setResult(step.canStepReturn()); - else - requestMonitor.setResult(false); - requestMonitor.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(createUpdateSchedulingRule()); - job.schedule(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepAdapter#isStepping(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - public void isStepping(final Object element, final IBooleanRequestMonitor requestMonitor) { - Job job = new Job("isStepping") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - IStep step = getTarget(element); - if (step != null) - requestMonitor.setResult(step.isStepping()); - else - requestMonitor.setResult(false); - requestMonitor.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.setRule(createUpdateSchedulingRule()); - job.schedule(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepAdapter#stepInto(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor) - */ - public void stepInto(final Object element, final IAsynchronousRequestMonitor requestMonitor) { - Job job = new Job("stepInto") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - IStep step = getTarget(element); - if (step != null) { - try { - step.stepInto(); - } catch (DebugException e) { - requestMonitor.setStatus(e.getStatus()); - } - } else { - requestMonitor.setStatus(new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.INTERNAL_ERROR, "element must be an instance of or adapt to IStep", //$NON-NLS-1$ - null)); - } - requestMonitor.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepAdapter#stepOver(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor) - */ - public void stepOver(final Object element, final IAsynchronousRequestMonitor requestMonitor) { - Job job = new Job("stepOver") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - IStep step = getTarget(element); - if (step != null) { - try { - step.stepOver(); - } catch (DebugException e) { - requestMonitor.setStatus(e.getStatus()); - } - } else { - requestMonitor.setStatus(new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.INTERNAL_ERROR, "element must be an instance of or adapt to IStep", //$NON-NLS-1$ - null)); - } - requestMonitor.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepAdapter#stepReturn(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor) - */ - public void stepReturn(final Object element, final IAsynchronousRequestMonitor requestMonitor) { - Job job = new Job("stepReturn") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - IStep step = getTarget(element); - if (step != null) { - try { - step.stepReturn(); - } catch (DebugException e) { - requestMonitor.setStatus(e.getStatus()); - } - } else { - requestMonitor.setStatus(new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.INTERNAL_ERROR, "element must be an instance of or adapt to IStep", //$NON-NLS-1$ - null)); - } - requestMonitor.done(); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); - - } - - private IStep getTarget(Object element) { - if (element instanceof IStep) { - return (IStep) element; - } else if (element instanceof IAdaptable) { - return (IStep) ((IAdaptable) element).getAdapter(IStep.class); - } - return null; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepFiltersAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepFiltersAdapter.java deleted file mode 100644 index 9012ab04d..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/StepFiltersAdapter.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -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; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepFiltersAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; - -/** - * Default step filters adapter for standard debug model. - * - * @since 3.2 - */ -public class StepFiltersAdapter extends StandardActionAdapter implements IAsynchronousStepFiltersAdapter { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepFiltersAdapter#supportsStepFilters(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - public void supportsStepFilters(final Object element, final IBooleanRequestMonitor requestMonitor) { - Job job = new Job("supportsStepFilters") { //$NON-NLS-1$ - protected IStatus run(IProgressMonitor monitor) { - boolean supported = false; - IDebugTarget[] debugTargets = getDebugTargets(element); - for (int i=0; i 0) { - Iterator itr = selection.iterator(); - while (itr.hasNext()) { - Object element = itr.next(); - isEnabledFor(element, monitor); - } - } else { - notSupported(monitor); - } - } - - /** - * Update the action enablement based on the launches present in the launch - * manager. - */ - protected void update(ISelection selection) { - super.update(getContext()); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getContext() - */ - protected IStructuredSelection getContext() { - return new StructuredSelection(DebugPlugin.getDefault() - .getLaunchManager().getLaunches()); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHelpContextId() - */ - public String getHelpContextId() { - return "terminate_all_action_context"; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getId() - */ - public String getId() { - return "org.eclipse.debug.ui.debugview.popupMenu.terminateAll"; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getText() - */ - public String getText() { - return ActionMessages.TerminateAllAction_2; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getToolTipText() - */ - public String getToolTipText() { - return ActionMessages.TerminateAllAction_3; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getDisabledImageDescriptor() - */ - public ImageDescriptor getDisabledImageDescriptor() { - return DebugPluginImages - .getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE_ALL); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHoverImageDescriptor() - */ - public ImageDescriptor getHoverImageDescriptor() { - return DebugPluginImages - .getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_ALL); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return DebugPluginImages - .getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_ALL); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRelaunchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRelaunchAction.java deleted file mode 100644 index 2bae2f2c0..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRelaunchAction.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 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 implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.context; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.ITerminate; -import org.eclipse.debug.internal.ui.DebugPluginImages; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.actions.ActionMessages; -import org.eclipse.debug.internal.ui.actions.RelaunchActionDelegate; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousTerminateAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * Action which terminates a launch and then re-launches it. - */ -public class TerminateAndRelaunchAction extends AbstractDebugContextAction { - - class RequestMonitor extends ActionRequestMonitor { - - private ILaunch fLaunch; - - public RequestMonitor(ILaunch launch) { - fLaunch = launch; - } - - public void done() { - super.done(); - DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { - // Must be run in the UI thread since the launch can require - // prompting to proceed - RelaunchActionDelegate.relaunch(fLaunch.getLaunchConfiguration(), fLaunch.getLaunchMode()); - } - }); - } - - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#doAction(java.lang.Object) - */ - protected void doAction(Object element) { - ILaunch launch = RelaunchActionDelegate.getLaunch(element); - if (launch == null || !(element instanceof ITerminate)) { - // Shouldn't happen because of enablement check. - return; - } - if (element instanceof IAdaptable) { - IAsynchronousTerminateAdapter adapter = (IAsynchronousTerminateAdapter) ((IAdaptable)element).getAdapter(IAsynchronousTerminateAdapter.class); - if (adapter != null) - adapter.terminate(element, new RequestMonitor(launch)); - } - } - - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#isEnabledFor(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) - */ - protected void isEnabledFor(Object element, IBooleanRequestMonitor monitor) { - if (element instanceof IAdaptable) { - IAsynchronousTerminateAdapter adapter = (IAsynchronousTerminateAdapter) ((IAdaptable)element).getAdapter(IAsynchronousTerminateAdapter.class); - if (adapter != null) { - ILaunch launch = RelaunchActionDelegate.getLaunch(element); - if(launch != null && LaunchConfigurationManager.isVisible(launch.getLaunchConfiguration())) { - adapter.canTerminate(element, monitor); - return; - } - } - } - notSupported(monitor); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.Action#getActionDefinitionId() - */ - public String getActionDefinitionId() { - return ActionMessages.TerminateAndRelaunchAction_0; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHelpContextId() - */ - public String getHelpContextId() { - return "terminate_and_relaunch_action_context"; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getId() - */ - public String getId() { - return "org.eclipse.debug.ui.debugview.popupMenu.TerminateAndRelaunch"; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getText() - */ - public String getText() { - return ActionMessages.TerminateAndRelaunchAction_3; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getToolTipText() - */ - public String getToolTipText() { - return ActionMessages.TerminateAndRelaunchAction_4; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getDisabledImageDescriptor() - */ - public ImageDescriptor getDisabledImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE_AND_RELAUNCH); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getHoverImageDescriptor() - */ - public ImageDescriptor getHoverImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_RELAUNCH); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_RELAUNCH); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRemoveAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRemoveAction.java deleted file mode 100644 index 25ee97983..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRemoveAction.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import org.eclipse.core.runtime.IAdaptable; -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.IProcess; -import org.eclipse.debug.internal.ui.DebugPluginImages; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.actions.ActionMessages; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousTerminateAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.jface.resource.ImageDescriptor; - -public class TerminateAndRemoveAction extends AbstractDebugContextAction { - - - class TerminateAndRemoveMonitor extends ActionRequestMonitor { - private Object fElement; - TerminateAndRemoveMonitor(Object element) { - fElement = element; - } - public void done() { - if(getStatus() == null) { - ILaunch launch= null; - - if (fElement instanceof ILaunch) { - launch= (ILaunch) fElement; - } else if (fElement instanceof IDebugElement) { - launch= ((IDebugElement) fElement).getLaunch(); - } else if (fElement instanceof IProcess) { - launch= ((IProcess) fElement).getLaunch(); - } - if (launch != null) - DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch); - } - super.done(); - } - - } - protected void doAction(Object element) { - if (element instanceof IAdaptable) { - IAsynchronousTerminateAdapter adapter = (IAsynchronousTerminateAdapter) ((IAdaptable)element).getAdapter(IAsynchronousTerminateAdapter.class); - if (adapter != null) - adapter.terminate(element, new TerminateAndRemoveMonitor(element)); - } - } - - - protected void isEnabledFor(Object element, IBooleanRequestMonitor monitor) { - if (element instanceof IAdaptable) { - IAsynchronousTerminateAdapter adapter = (IAsynchronousTerminateAdapter) ((IAdaptable)element).getAdapter(IAsynchronousTerminateAdapter.class); - if (adapter != null) { - adapter.canTerminate(element, monitor); - } else { - notSupported(monitor); - } - } - - } - - protected String getStatusMessage() { - return ActionMessages.TerminateAndRemoveActionDelegate_Exceptions_occurred_attempting_to_terminate_and_remove_2; - } - - protected String getErrorDialogMessage() { - return ActionMessages.TerminateAndRemoveActionDelegate_Terminate_and_remove_failed_1; - } - - public String getText() { - return ActionMessages.TerminateAndRemoveAction_0; - } - - public String getHelpContextId() { - return "terminate_and_remove_action_context"; //$NON-NLS-1$ - } - - public String getId() { - return "org.eclipse.debug.ui.debugview.popupMenu.terminateAndRemove"; //$NON-NLS-1$ - } - - public String getToolTipText() { - return ActionMessages.TerminateAndRemoveAction_3; - } - - public ImageDescriptor getDisabledImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE_AND_REMOVE); - } - - public ImageDescriptor getHoverImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_REMOVE); - } - - public ImageDescriptor getImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_REMOVE); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRemoveActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRemoveActionDelegate.java deleted file mode 100644 index 99509b9ac..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/TerminateAndRemoveActionDelegate.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.actions.context; - -public class TerminateAndRemoveActionDelegate extends AbstractDebugContextActionDelegate { - - public TerminateAndRemoveActionDelegate() { - super(); - setAction(new TerminateAndRemoveAction()); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ToggleStepFiltersAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ToggleStepFiltersAction.java deleted file mode 100644 index ba9eeb3b1..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ToggleStepFiltersAction.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * 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.actions.context; - -import java.util.Iterator; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.internal.ui.DebugPluginImages; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.actions.provisional.IAsynchronousStepFiltersAdapter; -import org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; - -public class ToggleStepFiltersAction extends AbstractDebugContextAction { - - public ToggleStepFiltersAction() - { - super(); - setEnabled(true); - } - - protected void doAction(Object target) { - // do nothing, the action is done by ToggleStepFiltersActionDelegate instead - // since this action does not have access to the checked state of the window button - } - - public ImageDescriptor getDisabledImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TOGGLE_STEP_FILTERS); - } - - public String getHelpContextId() { - return "step_with_filters_action_context"; //$NON-NLS-1$ - } - - public ImageDescriptor getHoverImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TOGGLE_STEP_FILTERS); - } - - public String getId() { - return "org.eclipse.debug.ui.actions.ToggleStepFilters"; //$NON-NLS-1$ - } - - public ImageDescriptor getImageDescriptor() { - return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TOGGLE_STEP_FILTERS); - } - - public String getText() { - // TODO: this #getText method is not currently used, putting non-nl string - // until properties files are opened to be updated again. - return "Toggle Step Filters"; //$NON-NLS-1$ - } - - public String getToolTipText() { - // TODO: this #getToolTipText method is not currently used, putting non-nl string - // until properties files are opened to be updated again. - return "Toggle Step Filters"; //$NON-NLS-1$ - } - - protected void isEnabledFor(Object element, IBooleanRequestMonitor monitor) { - if (element instanceof IAdaptable) - { - IAsynchronousStepFiltersAdapter stepFilters = (IAsynchronousStepFiltersAdapter)((IAdaptable)element).getAdapter(IAsynchronousStepFiltersAdapter.class); - if (stepFilters != null) - { - stepFilters.supportsStepFilters(element, monitor); - } - else - { - notSupported(monitor); - } - } - - } - - protected void updateEnableStateForContext(IStructuredSelection selection) { - - int size = selection.size(); - if (size == 1) - { - BooleanRequestMonitor monitor = new BooleanRequestMonitor(this, size); - - Iterator itr = selection.iterator(); - while (itr.hasNext()) { - Object element = itr.next(); - isEnabledFor(element, monitor); - } - } - else - { - BooleanRequestMonitor monitor = new BooleanRequestMonitor(this, 1); - monitor.setResult(true); - monitor.done(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction#getInitialEnablement() - */ - protected boolean getInitialEnablement() { - return true; - } - - - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ToggleStepFiltersActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ToggleStepFiltersActionDelegate.java deleted file mode 100644 index 409b450be..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/context/ToggleStepFiltersActionDelegate.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.actions.context; - -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; - -/** - * Turns step filters on/off for a selected target. - */ -public class ToggleStepFiltersActionDelegate extends AbstractDebugContextActionDelegate implements IPropertyChangeListener, IViewActionDelegate { - - - public ToggleStepFiltersActionDelegate() { - setAction(new ToggleStepFiltersAction()); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) - */ - public void init(IAction action) { - super.init(action); - getWindowAction().setChecked(isUseStepFilters()); - getPreferenceStore().addPropertyChangeListener(this); - } - - private boolean isUseStepFilters() { - return DebugUIPlugin.getDefault().getStepFilterManager().isUseStepFilters(); - } - - private IPreferenceStore getPreferenceStore() { - return DebugUIPlugin.getDefault().getPreferenceStore(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(IInternalDebugUIConstants.PREF_USE_STEP_FILTERS)) { - Object newValue = event.getNewValue(); - if (newValue instanceof Boolean) { - getWindowAction().setChecked(((Boolean)(newValue)).booleanValue()); - } else if (newValue instanceof String) { - getWindowAction().setChecked(Boolean.valueOf((String)newValue).booleanValue()); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() - */ - public void dispose() { - getPreferenceStore().removePropertyChangeListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - //this is to ensure that when the toolbar is initialized and run() gets called for checked items we don't immediately - //reverse our desired check state. - if(action instanceof Action) { - if(action.isChecked() != isUseStepFilters()) { - DebugUITools.setUseStepFilters(!isUseStepFilters()); - } - } - else { - DebugUITools.setUseStepFilters(!isUseStepFilters()); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) - */ - public void init(IViewPart view) { - init(view.getSite().getWorkbenchWindow()); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousDisconnectAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousDisconnectAdapter.java deleted file mode 100644 index bb603ca4e..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousDisconnectAdapter.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.actions.provisional; - -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; - -/** - * Adapter for disconnecting. - * - * @since 3.2 - */ -public interface IAsynchronousDisconnectAdapter { - - /** - * Asynchronously determines whether the given element can be disconnected. - * - * @param element element - * @param monitor request monitor - */ - public void canDisconnect(Object element, IBooleanRequestMonitor monitor); - - /** - * Asynchronously determines whether the given element is disconnected. - * - * @param element element - * @param monitor request monitor - */ - public void isDisconnected(Object element, IBooleanRequestMonitor monitor); - - /** - * Asynchronously disconnects the given element. - * - * @param element element - * @param monitor request monitor - */ - public void disconnect(Object element, IAsynchronousRequestMonitor monitor); -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousDropToFrameAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousDropToFrameAdapter.java deleted file mode 100644 index 513c18ab4..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousDropToFrameAdapter.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * 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.actions.provisional; - -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; - -/** - * Adapter for performing a drop to frame. - * - * @since 3.2 - */ -public interface IAsynchronousDropToFrameAdapter { - - /** - * Asynchronously determines whether the given element can perform a drop to frame. - * - * @param element element - * @param monitor request monitor - */ - public void canDropToFrame(Object element, IBooleanRequestMonitor monitor); - - /** - * Asynchronously drops to the given frame. - * - * @param element element - * @param monitor request monitor - */ - public void dropToFrame(Object element, IAsynchronousRequestMonitor monitor); -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousStepAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousStepAdapter.java deleted file mode 100644 index 129c1d018..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousStepAdapter.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * 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.actions.provisional; - -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; - -/** - * Adapter for stepping. - * - * @since 3.2 - */ -public interface IAsynchronousStepAdapter { - - /** - * Asynchronously determines whether the given element can perform a step into. - * - * @param element element - * @param monitor request monitor - */ - public void canStepInto(Object element, IBooleanRequestMonitor monitor); - /** - * Asynchronously determines whether the given element can perform a step over. - * - * @param element element - * @param monitor request monitor - */ - public void canStepOver(Object element, IBooleanRequestMonitor monitor); - /** - * Asynchronously determines whether the given element can perform a step return. - * - * @param element element - * @param monitor request monitor - */ - public void canStepReturn(Object element, IBooleanRequestMonitor monitor); - /** - * Asynchronously determines whether the given element is stepping. - * - * @param element element - * @param monitor request monitor - */ - public void isStepping(Object element, IBooleanRequestMonitor monitor); - /** - * Asynchronously performs a step into. - * - * @param element element - * @param monitor request monitor - */ - public void stepInto(Object element, IAsynchronousRequestMonitor monitor); - /** - * Asynchronously performs a step over. - * - * @param element element - * @param monitor request monitor - */ - public void stepOver(Object element, IAsynchronousRequestMonitor monitor); - /** - * Asynchronously performs a step return. - * - * @param element element - * @param monitor request monitor - */ - public void stepReturn(Object element, IAsynchronousRequestMonitor monitor); -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousStepFiltersAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousStepFiltersAdapter.java deleted file mode 100644 index 410b5306f..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousStepFiltersAdapter.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * 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.actions.provisional; - -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; - -/** - * Adapter for enabling and disabling step filters. - * - * @since 3.2 - */ -public interface IAsynchronousStepFiltersAdapter { - - /** - * Asynchronously determines whether the given element supports step filters. - * - * @param element element - * @param monitor request monitor - */ - public void supportsStepFilters(Object element, IBooleanRequestMonitor monitor); - /** - * Asynchronously determines whether step filters are enabled. - * - * @param element element - * @param monitor request monitor - */ - public void isStepFiltersEnabled(Object element, IBooleanRequestMonitor monitor); - /** - * Asynchronously enables or disables step filters on the given element. - * - * @param element element - * @param enabled whether step filters should be enabled - * @param monitor request monitor - */ - public void setStepFiltersEnabled(Object element, boolean enabled, IAsynchronousRequestMonitor monitor); -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousSuspendResumeAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousSuspendResumeAdapter.java deleted file mode 100644 index 85c83e34b..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousSuspendResumeAdapter.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * 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.actions.provisional; - -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; - -/** - * Adapter for suspending and resuming. - * - * @since 3.2 - */ -public interface IAsynchronousSuspendResumeAdapter { - - /** - * Asynchronously determines whether the given element can perform a resume. - * - * @param element element - * @param monitor request monitor - */ - public void canResume(Object element, IBooleanRequestMonitor monitor); - /** - * Asynchronously determines whether the given element can be suspended. - * - * @param element element - * @param monitor request monitor - */ - public void canSuspend(Object element, IBooleanRequestMonitor monitor); - /** - * Asynchronously determines whether the given element is suspended. - * - * @param element element - * @param monitor request monitor - */ - public void isSuspended(Object element, IBooleanRequestMonitor monitor); - /** - * Asynchronously resumes the given element. - * - * @param element element - * @param monitor request monitor - */ - public void resume(Object element, IAsynchronousRequestMonitor monitor); - /** - * Asynchronously suspends the given element. - * - * @param element element - * @param monitor request monitor - */ - public void suspend(Object element, IAsynchronousRequestMonitor monitor); - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousTerminateAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousTerminateAdapter.java deleted file mode 100644 index 2521774d7..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IAsynchronousTerminateAdapter.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.actions.provisional; - -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; - -/** - * Adapter for terminating. - * - * @since 3.2 - */ -public interface IAsynchronousTerminateAdapter { - - /** - * Asynchronously determines whether the given element can be terminated. - * - * @param element element - * @param monitor request monitor - */ - public void canTerminate(Object element, IBooleanRequestMonitor monitor); - - /** - * Asynchronously determines whether the given element is terminated. - * - * @param element element - * @param monitor request monitor - */ - public void isTerminated(Object element, IBooleanRequestMonitor monitor); - - /** - * Asynchronously terminates the given element. - * - * @param element element - * @param monitor request monitor - */ - public void terminate(Object element, IAsynchronousRequestMonitor monitor); -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IBooleanRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IBooleanRequestMonitor.java deleted file mode 100644 index e31dc2bb9..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/provisional/IBooleanRequestMonitor.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.actions.provisional; - -import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; - -/** - * Request monitor for obtaining a boolean result asynchronously. - * - * @since 3.2 - */ -public interface IBooleanRequestMonitor extends IAsynchronousRequestMonitor { - - /** - * Sets the result of a boolean request. - * - * @param result the result - */ - public void setResult(boolean result); -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DebugCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DebugCommand.java new file mode 100644 index 000000000..d838317d7 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DebugCommand.java @@ -0,0 +1,147 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.commands.provisional.IBooleanRequestMonitor; +import org.eclipse.debug.internal.ui.commands.provisional.IDebugCommand; +import org.eclipse.debug.internal.ui.viewers.AsynchronousSchedulingRuleFactory; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; +import org.eclipse.debug.ui.IDebugUIConstants; + +/** + * Common function for standard debug commands. + * + * @since 3.3 + * + */ +public abstract class DebugCommand implements IDebugCommand { + + // debug flag + public static boolean DEBUG_COMMANDS = false; + + static { + DEBUG_COMMANDS = DebugUIPlugin.DEBUG && "true".equals( //$NON-NLS-1$ + Platform.getDebugOption("org.eclipse.debug.ui/debug/commands")); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.commands.provisional.IDebugCommand#performCapability(java.lang.Object, org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor) + */ + public void execute(final Object element, final IAsynchronousRequestMonitor requestMonitor) { + Job job = new Job("execute command") { //$NON-NLS-1$ + protected IStatus run(IProgressMonitor monitor) { + if (DEBUG_COMMANDS) { + System.out.println("execute: " + DebugCommand.this); //$NON-NLS-1$ + } + Object target = getTarget(element); + if (target != null) { + try { + doExecute(target, requestMonitor); + } catch (CoreException e) { + requestMonitor.setStatus(e.getStatus()); + if (DEBUG_COMMANDS) { + System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$ + } + } + } else { + requestMonitor.setStatus(new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.INTERNAL_ERROR, "element did not adapt to capability", //$NON-NLS-1$ + null)); + } + requestMonitor.done(); + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.schedule(); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.commands.provisional.IDebugCommand#checkCapability(java.lang.Object, org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor) + */ + public void canExecute(final Object element, final IBooleanRequestMonitor requestMonitor) { + Job job = new Job("check command") { //$NON-NLS-1$ + protected IStatus run(IProgressMonitor monitor) { + if (DEBUG_COMMANDS) { + System.out.print("can execute command: " + DebugCommand.this); //$NON-NLS-1$ + } + Object target = getTarget(element); + if (target != null) { + try { + boolean executable = isExecutable(target, requestMonitor); + if (DEBUG_COMMANDS) { + System.out.println(" >> " + executable); //$NON-NLS-1$ + } + requestMonitor.setResult(executable); + } catch (CoreException e) { + requestMonitor.setStatus(e.getStatus()); + if (DEBUG_COMMANDS) { + System.out.println(" >> ABORTED"); //$NON-NLS-1$ + System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$ + } + } + } else { + requestMonitor.setResult(false); + if (DEBUG_COMMANDS) { + System.out.println(" >> false (no adapter)"); //$NON-NLS-1$ + } + } + requestMonitor.done(); + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.setRule(createUpdateSchedulingRule(element)); + job.schedule(); + + } + + /** + * Executes the actual operation. + * + * @param target object to perform on + * @param monitor progress monitor + */ + protected abstract void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException; + + /** + * Returns whether this command is executable. + * + * @param target object to check command for + * @param monitor progress monitor + * @return whether this command can be executed + */ + protected abstract boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException; + + /** + * Returns the appropriate command adapter from the given object. + * + * @param element object to obtain adapter from + * @return adapter + */ + protected abstract Object getTarget(Object element); + + /** + * Scheduling rule for checking capability. + * + * @return scheduling rule or null + */ + protected ISchedulingRule createUpdateSchedulingRule(Object element) { + return AsynchronousSchedulingRuleFactory.getDefault().newSerialPerObjectRule(element); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java new file mode 100644 index 000000000..cf01524ff --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DisconnectCommand.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.core.model.IDisconnect; +import org.eclipse.debug.internal.ui.commands.provisional.IDisconnectCommand; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * Default disconnect command for the standard debug model. + * + * @since 3.3 + */ +public class DisconnectCommand extends DebugCommand implements IDisconnectCommand { + + protected boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + return ((IDisconnect)target).canDisconnect(); + } + + protected void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + ((IDisconnect)target).disconnect(); + } + + protected Object getTarget(Object element) { + if (element instanceof IDisconnect) { + return element; + } else if (element instanceof IAdaptable) { + return ((IAdaptable) element).getAdapter(IDisconnect.class); + } + return null; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DropToFrameCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DropToFrameCommand.java new file mode 100644 index 000000000..8821a5c74 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/DropToFrameCommand.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.core.model.IDropToFrame; +import org.eclipse.debug.internal.ui.commands.provisional.IDropToFrameCommand; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * Default drop to frame command for the standard debug model. + * + * @since 3.3 + */ +public class DropToFrameCommand extends DebugCommand implements IDropToFrameCommand { + + protected boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + return ((IDropToFrame)target).canDropToFrame(); + } + + protected void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + ((IDropToFrame)target).dropToFrame(); + } + + protected Object getTarget(Object element) { + if (element instanceof IDropToFrame) { + return element; + } else if (element instanceof IAdaptable) { + return ((IAdaptable) element).getAdapter(IDropToFrame.class); + } + return null; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/ResumeCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/ResumeCommand.java new file mode 100644 index 000000000..e75739737 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/ResumeCommand.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.ISuspendResume; +import org.eclipse.debug.internal.ui.commands.provisional.IResumeCommand; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * Default resume command for the standard debug model. + * + * @since 3.3 + */ +public class ResumeCommand extends SuspendCommand implements IResumeCommand { + + protected boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + return ((ISuspendResume)target).canResume(); + } + + protected void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + ((ISuspendResume)target).resume(); + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepCommand.java new file mode 100644 index 000000000..6775b53f3 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepCommand.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.core.model.IStep; + +/** + * Common function for step commands. + * + * @since 3.3 + */ +public abstract class StepCommand extends DebugCommand { + + protected Object getTarget(Object element) { + if (element instanceof IStep) { + return element; + } else if (element instanceof IAdaptable) { + return ((IAdaptable) element).getAdapter(IStep.class); + } + return null; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepFiltersCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepFiltersCommand.java new file mode 100644 index 000000000..6394850ff --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepFiltersCommand.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +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; +import org.eclipse.debug.internal.ui.commands.provisional.IStepFiltersCommand; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; +import org.eclipse.debug.ui.DebugUITools; + +/** + * Default toggle step filters command for the standard debug model. + * + * @since 3.3 + */ +public class StepFiltersCommand extends DebugCommand implements IStepFiltersCommand { + + protected boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + IStepFilters[] filters = (IStepFilters[]) target; + for (int i = 0; i < filters.length; i++) { + IStepFilters filter = filters[i]; + if (filter == null || !filter.supportsStepFilters()) { + return false; + } + } + return true; + } + + protected void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + IStepFilters[] filters = (IStepFilters[]) target; + for (int i = 0; i < filters.length; i++) { + IStepFilters filter = filters[i]; + filter.setStepFiltersEnabled(DebugUITools.isUseStepFilters()); + } + } + + protected Object getTarget(Object element) { + IDebugTarget[] targets = getDebugTargets(element); + if (targets.length > 0) { + IStepFilters[] filters = new IStepFilters[targets.length]; + for (int i = 0; i < targets.length; i++) { + IDebugTarget target = targets[i]; + if (target instanceof IStepFilters) { + filters[i] = (IStepFilters) target; + } else { + filters[i] = (IStepFilters) ((IAdaptable)element).getAdapter(IStepFilters.class); + } + } + return filters; + } + return new IStepFilters[0]; + } + + private IDebugTarget[] getDebugTargets(Object element) { + if (element instanceof IDebugElement) { + IDebugElement debugElement = (IDebugElement) element; + return new IDebugTarget[] { debugElement.getDebugTarget() }; + } else if (element instanceof ILaunch) { + ILaunch launch = (ILaunch) element; + return launch.getDebugTargets(); + } else if (element instanceof IProcess) { + IProcess process = (IProcess) element; + return process.getLaunch().getDebugTargets(); + } else { + return new IDebugTarget[0]; + } + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepIntoCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepIntoCommand.java new file mode 100644 index 000000000..b419af29a --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepIntoCommand.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.IStep; +import org.eclipse.debug.internal.ui.commands.provisional.IStepIntoCommand; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * Default step into command for the standard debug model. + * + * @since 3.3 + */ +public class StepIntoCommand extends StepCommand implements IStepIntoCommand { + + protected boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + return ((IStep)target).canStepInto(); + } + + protected void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + ((IStep)target).stepInto(); + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepOverCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepOverCommand.java new file mode 100644 index 000000000..335759a14 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepOverCommand.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.IStep; +import org.eclipse.debug.internal.ui.commands.provisional.IStepOverCommand; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * Default step over command for the standard debug model. + * + * @since 3.3 + */ +public class StepOverCommand extends StepCommand implements IStepOverCommand { + + protected boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + return ((IStep)target).canStepOver(); + } + + protected void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + ((IStep)target).stepOver(); + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepReturnCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepReturnCommand.java new file mode 100644 index 000000000..2b5f4057d --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/StepReturnCommand.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.model.IStep; +import org.eclipse.debug.internal.ui.commands.provisional.IStepReturnCommand; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * Default step return command for the standard debug model. + * + * @since 3.3 + */ +public class StepReturnCommand extends StepCommand implements IStepReturnCommand { + + protected boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + return ((IStep)target).canStepReturn(); + } + + protected void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + ((IStep)target).stepReturn(); + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/SuspendCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/SuspendCommand.java new file mode 100644 index 000000000..6013edfbc --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/SuspendCommand.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.core.model.ISuspendResume; +import org.eclipse.debug.internal.ui.commands.provisional.ISuspendCommand; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * Default suspend command for the standard debug model. + * + * @since 3.3 + */ +public class SuspendCommand extends DebugCommand implements ISuspendCommand { + + protected boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + return ((ISuspendResume)target).canSuspend(); + } + + protected void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + ((ISuspendResume)target).suspend(); + } + + protected Object getTarget(Object element) { + if (element instanceof ISuspendResume) { + return element; + } else if (element instanceof IAdaptable) { + return ((IAdaptable) element).getAdapter(ISuspendResume.class); + } + return null; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/TerminateCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/TerminateCommand.java new file mode 100644 index 000000000..6ca8f73f1 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/TerminateCommand.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.commands; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.core.model.ITerminate; +import org.eclipse.debug.internal.ui.commands.provisional.ITerminateCommand; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * Default terminate command for the standard debug model. + * + * @since 3.3 + */ +public class TerminateCommand extends DebugCommand implements ITerminateCommand { + + protected boolean isExecutable(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + return ((ITerminate)target).canTerminate(); + } + + protected void doExecute(Object target, IAsynchronousRequestMonitor monitor) throws CoreException { + ((ITerminate)target).terminate(); + } + + protected Object getTarget(Object element) { + if (element instanceof ITerminate) { + return element; + } else if (element instanceof IAdaptable) { + return ((IAdaptable) element).getAdapter(ITerminate.class); + } + return null; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/AbstractRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/AbstractRequestMonitor.java new file mode 100644 index 000000000..bf06bda8a --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/AbstractRequestMonitor.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * Common function for request monitors + * + * @since 3.3 + * + */ +public abstract class AbstractRequestMonitor implements IAsynchronousRequestMonitor { + + private IStatus fStatus; + private boolean fCancelled = false; + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor#setStatus(org.eclipse.core.runtime.IStatus) + */ + public void setStatus(IStatus status) { + fStatus = status; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int) + */ + public void beginTask(String name, int totalWork) { + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double) + */ + public void internalWorked(double work) { + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled() + */ + public boolean isCanceled() { + return fCancelled; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean) + */ + public void setCanceled(boolean value) { + fCancelled = value; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String) + */ + public void setTaskName(String name) { + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String) + */ + public void subTask(String name) { + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#worked(int) + */ + public void worked(int work) { + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor#getStatus() + */ + public IStatus getStatus() { + return fStatus; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionAdapterFactory.java new file mode 100644 index 000000000..ca6378ca8 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionAdapterFactory.java @@ -0,0 +1,131 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.model.IDebugElement; +import org.eclipse.debug.core.model.IDisconnect; +import org.eclipse.debug.core.model.IDropToFrame; +import org.eclipse.debug.core.model.IProcess; +import org.eclipse.debug.core.model.IStep; +import org.eclipse.debug.core.model.ISuspendResume; +import org.eclipse.debug.core.model.ITerminate; +import org.eclipse.debug.internal.ui.commands.DisconnectCommand; +import org.eclipse.debug.internal.ui.commands.DropToFrameCommand; +import org.eclipse.debug.internal.ui.commands.ResumeCommand; +import org.eclipse.debug.internal.ui.commands.StepFiltersCommand; +import org.eclipse.debug.internal.ui.commands.StepIntoCommand; +import org.eclipse.debug.internal.ui.commands.StepOverCommand; +import org.eclipse.debug.internal.ui.commands.StepReturnCommand; +import org.eclipse.debug.internal.ui.commands.SuspendCommand; +import org.eclipse.debug.internal.ui.commands.TerminateCommand; +import org.eclipse.debug.internal.ui.commands.provisional.IDisconnectCommand; +import org.eclipse.debug.internal.ui.commands.provisional.IDropToFrameCommand; +import org.eclipse.debug.internal.ui.commands.provisional.IResumeCommand; +import org.eclipse.debug.internal.ui.commands.provisional.IStepFiltersCommand; +import org.eclipse.debug.internal.ui.commands.provisional.IStepIntoCommand; +import org.eclipse.debug.internal.ui.commands.provisional.IStepOverCommand; +import org.eclipse.debug.internal.ui.commands.provisional.IStepReturnCommand; +import org.eclipse.debug.internal.ui.commands.provisional.ISuspendCommand; +import org.eclipse.debug.internal.ui.commands.provisional.ITerminateCommand; + +/** + * Adapter factory for debug capabilities. + * + * @since 3.3 + * + */ +public class ActionAdapterFactory implements IAdapterFactory { + + + private static ITerminateCommand fgTerminateCommand = new TerminateCommand(); + private static IStepOverCommand fgStepOverCommand = new StepOverCommand(); + private static IStepIntoCommand fgStepIntoCommand = new StepIntoCommand(); + private static IStepReturnCommand fgStepReturnCommand = new StepReturnCommand(); + private static IDropToFrameCommand fgDropToFrameCommand = new DropToFrameCommand(); + private static IDisconnectCommand fgDisconnectCommand = new DisconnectCommand(); + private static ISuspendCommand fgSuspendCommand = new SuspendCommand(); + private static IResumeCommand fgResumeCommand = new ResumeCommand(); + private static IStepFiltersCommand fgStepFiltersCommand = new StepFiltersCommand(); + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) + */ + public Object getAdapter(Object adaptableObject, Class adapterType) { + if (IStepFiltersCommand.class.equals(adapterType)) { + if (adaptableObject instanceof IDebugElement || + adaptableObject instanceof ILaunch || + adaptableObject instanceof IProcess) { + return fgStepFiltersCommand; + } + } + + if (ITerminateCommand.class.equals(adapterType)) { + if (adaptableObject instanceof ITerminate) { + return fgTerminateCommand; + } + } + if (IStepOverCommand.class.equals(adapterType)) { + if (adaptableObject instanceof IStep) { + return fgStepOverCommand; + } + } + if (IStepIntoCommand.class.equals(adapterType)) { + if (adaptableObject instanceof IStep) { + return fgStepIntoCommand; + } + } + if (IStepReturnCommand.class.equals(adapterType)) { + if (adaptableObject instanceof IStep) { + return fgStepReturnCommand; + } + } + if (ISuspendCommand.class.equals(adapterType)) { + if (adaptableObject instanceof ISuspendResume) { + return fgSuspendCommand; + } + } + if (IResumeCommand.class.equals(adapterType)) { + if (adaptableObject instanceof ISuspendResume) { + return fgResumeCommand; + } + } + if (IDisconnectCommand.class.equals(adapterType)) { + if (adaptableObject instanceof IDisconnect) { + return fgDisconnectCommand; + } + } + if (IDropToFrameCommand.class.equals(adapterType)) { + if (adaptableObject instanceof IDropToFrame) { + return fgDropToFrameCommand; + } + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() + */ + public Class[] getAdapterList() { + return new Class[]{ + ITerminateCommand.class, + IStepOverCommand.class, + IStepIntoCommand.class, + IStepReturnCommand.class, + ISuspendCommand.class, + IResumeCommand.class, + IDropToFrameCommand.class, + IDisconnectCommand.class, + IStepFiltersCommand.class}; + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionRequestMonitor.java new file mode 100644 index 000000000..9a9de76d3 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ActionRequestMonitor.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.internal.ui.DebugUIMessages; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.jface.dialogs.MessageDialog; + +/** + * Plain request monitor for actions. Has no result. + * + * @since 3.3 + * + */ +public class ActionRequestMonitor extends AbstractRequestMonitor { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.IProgressMonitor#done() + */ + public void done() { + final IStatus status = getStatus(); + if (status != null) { + switch (status.getSeverity()) { + case IStatus.ERROR: + DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { + public void run() { + MessageDialog.openError(DebugUIPlugin.getShell(), DebugUIMessages.DebugUITools_Error_1, status.getMessage()); + } + }); + break; + case IStatus.WARNING: + DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { + public void run() { + MessageDialog.openWarning(DebugUIPlugin.getShell(), DebugUIMessages.DebugUITools_Error_1, status.getMessage()); + } + }); + break; + case IStatus.INFO: + DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { + public void run() { + MessageDialog.openInformation(DebugUIPlugin.getShell(), DebugUIMessages.DebugUITools_Error_1, status.getMessage()); + } + }); + break; + } + } + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/BooleanRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/BooleanRequestMonitor.java new file mode 100644 index 000000000..ae6d99a69 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/BooleanRequestMonitor.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.debug.internal.ui.commands.provisional.IBooleanRequestMonitor; +import org.eclipse.jface.action.IAction; + +/** + * Boolean request monitor that collects boolean results from a number of voters. + * Request is cancelled when one voter votes false. + * + * @since 3.3 + * + */ +public class BooleanRequestMonitor extends AbstractRequestMonitor implements IBooleanRequestMonitor { + + private IAction fAction; + private int fNumVoters; + private int fNumOfVotes = 0; + + public BooleanRequestMonitor(IAction action, int numVoters) { + fAction = action; + fNumVoters = numVoters; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor#setResult(boolean) + */ + public void setResult(boolean result) { + fNumOfVotes++; + if (!isCanceled()) { + if (!result) { + setCanceled(true); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#done() + */ + public void done() { + if (isCanceled()) { + fAction.setEnabled(false); + } else { + fAction.setEnabled(fNumOfVotes == fNumVoters); + } + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/CommandMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/CommandMonitor.java new file mode 100644 index 000000000..c037ff2ed --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/CommandMonitor.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.debug.internal.ui.commands.provisional.IBooleanRequestMonitor; +import org.eclipse.jface.action.IAction; + +/** + * Request monitor for a command action. + * + * @since 3.3 + */ +public class CommandMonitor extends AbstractRequestMonitor implements IBooleanRequestMonitor { + + private IAction fAction; + + public CommandMonitor(IAction action) { + fAction = action; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor#setResult(boolean) + */ + public void setResult(boolean result) { + setCanceled(!result); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#done() + */ + public void done() { + fAction.setEnabled(!isCanceled()); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandAction.java new file mode 100644 index 000000000..230908e5d --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandAction.java @@ -0,0 +1,269 @@ +/******************************************************************************* + * 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.commands.actions; + +import java.util.Iterator; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.internal.ui.commands.provisional.IDebugCommand; +import org.eclipse.debug.internal.ui.contexts.DebugContextManager; +import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener; +import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextManager; +import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextService; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Event; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * Abstract base class for actions performing debug commands + * + * @since 3.3 + */ +public abstract class DebugCommandAction extends Action implements IDebugContextListener { + + /** + * The window this action is working for. + */ + private IWorkbenchWindow fWindow; + + /** + * The part this action is working for, or null if global to + * a window. + */ + private IWorkbenchPart fPart; + + /** + * Command service. + */ + private DebugCommandService fUpdateService; + + /** + * Delegate this action is working for or null if none. + */ + private DebugCommandActionDelegate fDelegate; + + /** + * Constructor + */ + public DebugCommandAction() { + super(); + String helpContextId = getHelpContextId(); + if (helpContextId != null) + PlatformUI.getWorkbench().getHelpSystem().setHelp(this, helpContextId); + setEnabled(false); + } + + /** + * Set the current delegate + * @param delegate + */ + public void setDelegate(DebugCommandActionDelegate delegate) { + fDelegate = delegate; + } + + /** + * This method is analagous to the standard 'run' method for an IAction + * @param target the target to perform the action on + */ + protected void execute(Object target) { + if (target instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable) target; + IDebugCommand capability = (IDebugCommand) adaptable.getAdapter(getCommandType()); + if (capability != null) { + capability.execute(target, createStatusMonitor(target)); + } + } + } + + /** + * Creates and returns the status monitor to execute this action with. + * + * @param target target of the command + * @return status monitor to execute with + */ + protected IAsynchronousRequestMonitor createStatusMonitor(Object target) { + return new ActionRequestMonitor(); + } + + /** + * Returns the command type this action executes. + * + * @return command class. + */ + abstract protected Class getCommandType(); + + public void contextActivated(ISelection context, IWorkbenchPart part) { + fUpdateService.postUpdateCommand(getCommandType(), new CommandMonitor(this)); + } + + public void contextChanged(ISelection context, IWorkbenchPart part) { + contextActivated(context, part); + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.Action#setEnabled(boolean) + */ + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + if (fDelegate != null) { + fDelegate.setEnabled(enabled); + } + } + + /** + * Initializes this action for a specific part. + * + * @param part workbench part + */ + public void init(IWorkbenchPart part) { + fPart = part; + fWindow = part.getSite().getWorkbenchWindow(); + fUpdateService = DebugCommandService.getService(fWindow); + IDebugContextService service = DebugContextManager.getDefault().getContextService(fWindow); + String partId = part.getSite().getId(); + service.addDebugContextListener(this, partId); + ISelection activeContext = service.getActiveContext(partId); + if (activeContext != null) { + fUpdateService.updateCommand(getCommandType(), new CommandMonitor(this)); + } else { + setEnabled(getInitialEnablement()); + } + } + + /** + * Initializes the context action + * @param window the window + */ + public void init(IWorkbenchWindow window) { + fWindow = window; + fUpdateService = DebugCommandService.getService(fWindow); + IDebugContextManager manager = DebugContextManager.getDefault(); + manager.addDebugContextListener(this, window); + ISelection activeContext = manager.getActiveContext(window); + if (activeContext != null) { + fUpdateService.updateCommand(getCommandType(), new BooleanRequestMonitor(this, 1)); + } else { + setEnabled(getInitialEnablement()); + } + } + + /** + * Returns whether this action should be enabled when initialized + * and there is no active debug context. + * + * @return false, by default + */ + protected boolean getInitialEnablement() { + return false; + } + + /** + * Returns the most recent selection + * + * @return structured selection + */ + protected ISelection getContext() { + if (fPart != null) { + DebugContextManager.getDefault().getContextService(fWindow).getActiveContext(fPart.getSite().getId()); + } + return DebugContextManager.getDefault().getActiveContext(fWindow); + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.Action#run() + */ + public void run() { + ISelection selection = getContext(); + if (selection instanceof IStructuredSelection && isEnabled()) { + // disable the action so it cannot be run again until an event or + // selection change updates the enablement + setEnabled(false); + IStructuredSelection ss = (IStructuredSelection) selection; + for (Iterator iter = ss.iterator(); iter.hasNext();) { + Object element = iter.next(); + execute(element); + } + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event) + */ + public void runWithEvent(Event event) { + run(); + } + + /** + * Clean up when removing + */ + public void dispose() { + IDebugContextManager manager = DebugContextManager.getDefault(); + if (fPart != null) { + IDebugContextService service = manager.getContextService(fWindow); + service.removeDebugContextListener(this, fPart.getSite().getId()); + } else { + manager.removeDebugContextListener(this, fWindow); + } + fWindow = null; + fPart = null; + } + + /** + * @return The help context id for this action + */ + public abstract String getHelpContextId(); + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.Action#getId() + */ + public abstract String getId(); + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.Action#getText() + */ + public abstract String getText(); + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.Action#getToolTipText() + */ + public abstract String getToolTipText(); + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor() + */ + public abstract ImageDescriptor getDisabledImageDescriptor(); + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.Action#getHoverImageDescriptor() + */ + public abstract ImageDescriptor getHoverImageDescriptor(); + + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.Action#getImageDescriptor() + */ + public abstract ImageDescriptor getImageDescriptor(); +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java new file mode 100644 index 000000000..db973418d --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2000, 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.commands.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Event; +import org.eclipse.ui.IActionDelegate2; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +/** + * Abstract base class for debug action delegates performing debug commands. + * + * @since 3.3 + */ +public abstract class DebugCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 { + + /** + *The real action for this delegate + */ + private DebugCommandAction fDebugAction; + + /** + * The underlying action for this delegate + */ + private IAction fWindowAction; + + /** + * Whether this action has been initialized before it has been run + * (ensures enablement state is up to date when lazily instantiated) + */ + private boolean fInitialized = false; + + public DebugCommandActionDelegate() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + public void dispose() { + fDebugAction.dispose(); + + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) + */ + public void init(IAction action) { + fWindowAction = action; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public void init(IWorkbenchWindow window) { + fDebugAction.init(window); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public synchronized void run(IAction action) { + if (!fInitialized) { + try { + wait(); + } catch (InterruptedException e) { + } + } + fDebugAction.run(); + } + + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) + */ + public void runWithEvent(IAction action, Event event) { + run(action); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection s) { + // do nothing + } + + protected DebugCommandAction getAction() { + return fDebugAction; + } + + protected void setAction(DebugCommandAction action) { + fDebugAction = action; + action.setDelegate(this); + } + + public synchronized void setEnabled(boolean enabled) { + if (!fInitialized) { + fInitialized = true; + notifyAll(); + } + fWindowAction.setEnabled(enabled); + } + + protected IAction getWindowAction() + { + return fWindowAction; + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java new file mode 100644 index 000000000..2ef382fe7 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java @@ -0,0 +1,205 @@ +/******************************************************************************* + * 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.commands.actions; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.internal.ui.commands.provisional.IBooleanRequestMonitor; +import org.eclipse.debug.internal.ui.commands.provisional.IDebugCommand; +import org.eclipse.debug.internal.ui.contexts.DebugContextManager; +import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener; +import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextService; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWindowListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * Updates commands for a window. Coalesces update requests by command type. + * + * @since 3.3 + */ +public class DebugCommandService implements IDebugContextListener { + + /** + * Maps command types to update monitors + */ + private Map fCommandUpdates = new HashMap(); + + /** + * Window this service is for. + */ + private IWorkbenchWindow fWindow = null; + + /** + * The context service for this command service. + */ + private IDebugContextService fContextService = null; + + /** + * Service per window + */ + private static Map fgServices = new HashMap(); + + /** + * Returns the service for a window. + * + * @param window + * @return service + */ + public synchronized static DebugCommandService getService(IWorkbenchWindow window) { + DebugCommandService service = (DebugCommandService) fgServices.get(window); + if (service == null) { + service = new DebugCommandService(window); + fgServices.put(window, service); + } + return service; + } + + public DebugCommandService(IWorkbenchWindow window) { + fWindow = window; + fContextService = DebugContextManager.getDefault().getContextService(window); + fContextService.addPostDebugContextListener(this); + PlatformUI.getWorkbench().addWindowListener(new IWindowListener() { + + public void windowOpened(IWorkbenchWindow window) { + } + + public void windowDeactivated(IWorkbenchWindow window) { + } + + public void windowClosed(IWorkbenchWindow window) { + if (fWindow == window) { + dispose(); + } + } + + public void windowActivated(IWorkbenchWindow window) { + } + + }); + } + + private void dispose() { + fContextService.removeDebugContextListener(this); + fgServices.remove(fWindow); + fCommandUpdates.clear(); + fWindow = null; + } + + /** + * Updates the given command type after the next context change. + * + * @param commandType + * @param monitor + */ + public void postUpdateCommand(Class commandType, IBooleanRequestMonitor monitor) { + ProxyBooleanRequestMonitor proxy = (ProxyBooleanRequestMonitor) fCommandUpdates.get(commandType); + if (proxy == null) { + proxy = new ProxyBooleanRequestMonitor(); + fCommandUpdates.put(commandType, proxy); + } + proxy.addMonitor(monitor); + } + + /** + * Updates the given command type based on the active context. + * + * @param commandType + * @param requestMonitor + */ + public void updateCommand(Class commandType, IBooleanRequestMonitor requestMonitor) { + ISelection context = fContextService.getActiveContext(); + if (context instanceof IStructuredSelection && !context.isEmpty()) { + Object[] elements = ((IStructuredSelection)context).toArray(); + ProxyBooleanRequestMonitor monitor = new ProxyBooleanRequestMonitor(); + monitor.addMonitor(requestMonitor); + updateCommand(commandType, elements, monitor); + } else { + requestMonitor.setCanceled(true); + requestMonitor.done(); + } + } + + private void postUpdate(ISelection context) { + if (context instanceof IStructuredSelection && !context.isEmpty()) { + Object[] elements = ((IStructuredSelection)context).toArray(); + Iterator iterator = fCommandUpdates.entrySet().iterator(); + while (iterator.hasNext()) { + Entry entry = (Entry) iterator.next(); + Class commandType = (Class)entry.getKey(); + ProxyBooleanRequestMonitor monitor = (ProxyBooleanRequestMonitor) entry.getValue(); + updateCommand(commandType, elements, monitor); + } + } else { + Iterator iterator = fCommandUpdates.values().iterator(); + while (iterator.hasNext()) { + ProxyBooleanRequestMonitor monitor = (ProxyBooleanRequestMonitor) iterator.next(); + monitor.setCanceled(true); + monitor.done(); + } + } + fCommandUpdates.clear(); + } + + /** + * Updates the given command type for the specified elements. + * + * @param commandType command class to update + * @param elements elements to update for + * @param monitor status monitor + */ + private void updateCommand(Class commandType, Object[] elements, ProxyBooleanRequestMonitor monitor) { + IDebugCommand[] commands = new IDebugCommand[elements.length]; + int numVoters = 0; + for (int i = 0; i < elements.length; i++) { + Object element = elements[i]; + if (element instanceof IAdaptable) { + IDebugCommand command = (IDebugCommand) ((IAdaptable)element).getAdapter(commandType); + if (command != null) { + commands[i] = command; + numVoters++; + } else { + monitor.setCanceled(true); + monitor.done(); + return; + } + } + } + if (!monitor.isCanceled()) { + monitor.setNumVoters(numVoters); + for (int i = 0; i < commands.length; i++) { + IDebugCommand command = commands[i]; + command.canExecute(elements[i], monitor); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener#contextActivated(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart, org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextService) + */ + public void contextActivated(ISelection selection, IWorkbenchPart part) { + postUpdate(selection); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener#contextChanged(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart, org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextService) + */ + public void contextChanged(ISelection selection, IWorkbenchPart part) { + postUpdate(selection); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DisconnectCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DisconnectCommandAction.java new file mode 100644 index 000000000..8b3f43f04 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DisconnectCommandAction.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.IDisconnectCommand; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.resource.ImageDescriptor; +/** + * Disconnect action. + * + * @since 3.3 + */ +public class DisconnectCommandAction extends DebugCommandAction{ + + public String getText() { + return ActionMessages.DisconnectAction_0; + } + + public String getHelpContextId() { + return "disconnect_action_context"; //$NON-NLS-1$ + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.toolbar.disconnect"; //$NON-NLS-1$ + } + + public String getToolTipText() { + return ActionMessages.DisconnectAction_3; + } + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_DISCONNECT); + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_DISCONNECT); + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_DISCONNECT); + } + + protected Class getCommandType() { + return IDisconnectCommand.class; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DropToFrameCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DropToFrameCommandAction.java new file mode 100644 index 000000000..1f93ed617 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/DropToFrameCommandAction.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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.internal.ui.commands.actions; + +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.IDropToFrameCommand; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * Drop to frame action. + * + * @since 3.3 + */ +public class DropToFrameCommandAction extends DebugCommandAction { + + public String getText() { + return ActionMessages.DropToFrameAction_0; + } + + public String getHelpContextId() { + return "drop_to_frame_action_context"; //$NON-NLS-1$ + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.toolbar.dropToFrame"; //$NON-NLS-1$ + } + + public String getToolTipText() { + return ActionMessages.DropToFrameAction_3; + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DROP_TO_FRAME); + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DROP_TO_FRAME); + } + + public ImageDescriptor getDisabledImageDescriptor() { + return null; + } + + protected Class getCommandType() { + return IDropToFrameCommand.class; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ProxyBooleanRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ProxyBooleanRequestMonitor.java new file mode 100644 index 000000000..257744464 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ProxyBooleanRequestMonitor.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * 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.commands.actions; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.debug.internal.ui.commands.provisional.IBooleanRequestMonitor; + +/** + * Boolean request monitor that collects boolean results from a number of voters. + * Request is cancelled when one voter votes false. Forwards the results to + * any number of boolean request monitors. + * + * @since 3.3 + * + */ +public class ProxyBooleanRequestMonitor extends AbstractRequestMonitor implements IBooleanRequestMonitor { + + private List fMonitors = new ArrayList(); + private int fNumVoters; + private int fNumOfVotes = 0; + private boolean fDone = false; + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.actions.provisional.IBooleanRequestMonitor#setResult(boolean) + */ + public synchronized void setResult(boolean result) { + fNumOfVotes++; + if (!isCanceled()) { + if (!result) { + setCanceled(true); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IProgressMonitor#done() + */ + public synchronized void done() { + if (!fDone) { + if (isCanceled() || fNumOfVotes == fNumVoters) { + fDone = true; + Iterator monitors = fMonitors.iterator(); + while (monitors.hasNext()) { + IBooleanRequestMonitor monitor = (IBooleanRequestMonitor) monitors.next(); + monitor.setStatus(getStatus()); + if (isCanceled()) { + monitor.setCanceled(true); + } else { + monitor.setResult(true); + } + monitor.done(); + } + fMonitors.clear(); + } + } + } + + /** + * Sets the number of voters required for this capability test. + * + * @param numVoters + */ + void setNumVoters(int numVoters) { + fNumVoters = numVoters; + } + + /** + * Adds the given monitor to forward the result to when done. + * + * @param monitor + */ + void addMonitor(IBooleanRequestMonitor monitor) { + fMonitors.add(monitor); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandAction.java new file mode 100644 index 000000000..5f1cf0cf3 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandAction.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.IResumeCommand; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * Resume action. + * + * @since 3.3 + */ +public class ResumeCommandAction extends DebugCommandAction{ + + public ResumeCommandAction() { + setActionDefinitionId("org.eclipse.debug.ui.commands.Resume"); //$NON-NLS-1$ + } + + public String getText() { + return ActionMessages.ResumeAction_0; + } + + public String getHelpContextId() { + return "resume_action_context"; //$NON-NLS-1$ + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.toolbar.resume"; //$NON-NLS-1$ + } + + public String getToolTipText() { + return ActionMessages.ResumeAction_3; + } + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_RESUME); + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESUME); + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESUME); + } + + protected Class getCommandType() { + return IResumeCommand.class; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java new file mode 100644 index 000000000..77a6cb6d2 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2000, 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.commands.actions; + +/** + * Resume action delegate. + * + * @since 3.3 + */ +public class ResumeCommandActionDelegate extends DebugCommandActionDelegate { + + public ResumeCommandActionDelegate() { + super(); + setAction(new ResumeCommandAction()); + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandAction.java new file mode 100644 index 000000000..45ae8d711 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandAction.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.IStepIntoCommand; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * Step into action + * + * @since 3.3 + */ +public class StepIntoCommandAction extends DebugCommandAction { + + public StepIntoCommandAction() { + setActionDefinitionId("org.eclipse.debug.ui.commands.StepInto"); //$NON-NLS-1$ + } + + public String getText() { + return ActionMessages.StepIntoAction_0; + } + + public String getHelpContextId() { + return "step_into_action_context"; //$NON-NLS-1$ + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.toolbar.stepInto"; //$NON-NLS-1$ + } + + public String getToolTipText() { + return ActionMessages.StepIntoAction_3; + } + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_STEP_INTO); + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_STEP_INTO); + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_STEP_INTO); + } + + protected Class getCommandType() { + return IStepIntoCommand.class; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandActionDelegate.java new file mode 100644 index 000000000..0364de6eb --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandActionDelegate.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2000, 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.commands.actions; + +/** + * Step into action delegate. + * + * @since 3.3 + */ +public class StepIntoCommandActionDelegate extends DebugCommandActionDelegate { + + public StepIntoCommandActionDelegate() { + super(); + setAction(new StepIntoCommandAction()); + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandAction.java new file mode 100644 index 000000000..e33e2e407 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandAction.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.IStepOverCommand; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * Step over action. + * + * @since 3.3 + */ +public class StepOverCommandAction extends DebugCommandAction { + + public StepOverCommandAction() { + setActionDefinitionId("org.eclipse.debug.ui.commands.StepOver"); //$NON-NLS-1$ + } + + public String getText() { + return ActionMessages.StepOverAction_0; + } + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_STEP_OVER); + } + + public String getHelpContextId() { + return "step_over_action_context"; //$NON-NLS-1$ + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_STEP_OVER); + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.toolbar.stepOver"; //$NON-NLS-1$ + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_STEP_OVER); + } + + public String getToolTipText() { + return ActionMessages.StepOverAction_3; + } + + protected Class getCommandType() { + return IStepOverCommand.class; + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandActionDelegate.java new file mode 100644 index 000000000..71a20406d --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandActionDelegate.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2000, 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.commands.actions; + +/** + * Step over action delegate. + * + * @since 3.3 + */ +public class StepOverCommandActionDelegate extends DebugCommandActionDelegate { + + public StepOverCommandActionDelegate() { + super(); + setAction(new StepOverCommandAction()); + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandAction.java new file mode 100644 index 000000000..7bf961264 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandAction.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.IStepReturnCommand; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * Step return action. + * + * @since 3.3 + */ +public class StepReturnCommandAction extends DebugCommandAction { + + + public StepReturnCommandAction() { + setActionDefinitionId("org.eclipse.debug.ui.commands.StepReturn"); //$NON-NLS-1$ + } + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_STEP_RETURN); + } + + public String getHelpContextId() { + return "step_return_action_context"; //$NON-NLS-1$ + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_STEP_RETURN); + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.toolbar.stepReturn"; //$NON-NLS-1$ + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_STEP_RETURN); + } + + public String getToolTipText() { + return ActionMessages.StepReturnAction_2; + } + + public String getText() { + return ActionMessages.StepReturnAction_3; + } + + protected Class getCommandType() { + return IStepReturnCommand.class; + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandActionDelegate.java new file mode 100644 index 000000000..2f78cced1 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandActionDelegate.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2000, 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.commands.actions; + +/** + * Step return action delegate. + * + * @since 3.3 + */ +public class StepReturnCommandActionDelegate extends DebugCommandActionDelegate { + + public StepReturnCommandActionDelegate() { + super(); + setAction(new StepReturnCommandAction()); + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandAction.java new file mode 100644 index 000000000..98602fd58 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandAction.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.ISuspendCommand; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * Suspend action. + * + * @since 3.3 + */ +public class SuspendCommandAction extends DebugCommandAction { + + + public String getText() { + return ActionMessages.SuspendAction_0; + } + + public String getHelpContextId() { + return "suspend_action_context"; //$NON-NLS-1$ + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.toolbar.suspend"; //$NON-NLS-1$ + } + + public String getToolTipText() { + return ActionMessages.SuspendAction_3; + } + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_SUSPEND); + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_SUSPEND); + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_SUSPEND); + } + + protected Class getCommandType() { + return ISuspendCommand.class; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandActionDelegate.java new file mode 100644 index 000000000..9747cdc42 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandActionDelegate.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2000, 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.commands.actions; + +/** + * Suspend action delegate. + * + * @since 3.3 + */ +public class SuspendCommandActionDelegate extends DebugCommandActionDelegate { + + public SuspendCommandActionDelegate() { + super(); + setAction(new SuspendCommandAction()); + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllAction.java new file mode 100644 index 000000000..777167a50 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllAction.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2000, 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.commands.actions; + +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.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.ITerminateCommand; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Terminates all launches. + * + * @since 3.3 + */ +public class TerminateAllAction extends DebugCommandAction implements ILaunchesListener2 { + + protected ISelection getContext() { + return new StructuredSelection(getLaunchManager().getLaunches()); + } + + public void contextActivated(ISelection context, IWorkbenchPart part) { + // DO NOTHING + } + + public void contextChanged(ISelection context, IWorkbenchPart part) { + // DO NOTHING + } + + public void dispose() { + getLaunchManager().removeLaunchListener(this); + super.dispose(); + } + + public void init(IWorkbenchPart part) { + super.init(part); + ILaunchManager launchManager = getLaunchManager(); + launchManager.addLaunchListener(this); + // heuristic... rather than updating all the time, just assume there's + // something that's not terminated. + setEnabled(launchManager.getLaunches().length > 0); + } + + private ILaunchManager getLaunchManager() { + return DebugPlugin.getDefault().getLaunchManager(); + } + + public String getHelpContextId() { + return "terminate_all_action_context"; //$NON-NLS-1$ + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.popupMenu.terminateAll"; //$NON-NLS-1$ + } + + public String getText() { + return ActionMessages.TerminateAllAction_2; + } + + public String getToolTipText() { + return ActionMessages.TerminateAllAction_3; + } + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages + .getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE_ALL); + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages + .getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_ALL); + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages + .getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_ALL); + } + + protected Class getCommandType() { + return ITerminateCommand.class; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.ILaunchesListener2#launchesTerminated(org.eclipse.debug.core.ILaunch[]) + */ + public void launchesTerminated(ILaunch[] launches) { + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug.core.ILaunch[]) + */ + public void launchesAdded(ILaunch[] launches) { + setEnabled(true); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch[]) + */ + public void launchesChanged(ILaunch[] launches) { + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.debug.core.ILaunch[]) + */ + public void launchesRemoved(ILaunch[] launches) { + setEnabled(getLaunchManager().getLaunches().length > 0); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java new file mode 100644 index 000000000..146967d45 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2004, 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 implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.commands.actions; + +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.actions.RelaunchActionDelegate; +import org.eclipse.debug.internal.ui.commands.provisional.ITerminateCommand; +import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbenchPart; + +/** + * Action which terminates a launch and then re-launches it. + */ +public class TerminateAndRelaunchAction extends DebugCommandAction { + + class RequestMonitor extends ActionRequestMonitor { + + private ILaunch fLaunch; + + public RequestMonitor(ILaunch launch) { + fLaunch = launch; + } + + public void done() { + super.done(); + DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() { + public void run() { + // Must be run in the UI thread since the launch can require + // prompting to proceed + RelaunchActionDelegate.relaunch(fLaunch.getLaunchConfiguration(), fLaunch.getLaunchMode()); + } + }); + } + + } + + protected IAsynchronousRequestMonitor createStatusMonitor(Object target) { + ILaunch launch = RelaunchActionDelegate.getLaunch(target); + return new RequestMonitor(launch); + } + + protected Class getCommandType() { + return ITerminateCommand.class; + } + + public void contextActivated(ISelection context, IWorkbenchPart part) { + if (context instanceof IStructuredSelection) { + Object[] elements = ((IStructuredSelection)context).toArray(); + for (int i = 0; i < elements.length; i++) { + if (!canRelaunch(elements[i])) { + setEnabled(false); + return; + } + } + } + super.contextActivated(context, part); + } + + protected boolean canRelaunch(Object element) { + ILaunch launch = RelaunchActionDelegate.getLaunch(element); + return launch != null && LaunchConfigurationManager.isVisible(launch.getLaunchConfiguration()); + } + + public String getActionDefinitionId() { + return ActionMessages.TerminateAndRelaunchAction_0; + } + + public String getHelpContextId() { + return "terminate_and_relaunch_action_context"; //$NON-NLS-1$ + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.popupMenu.TerminateAndRelaunch"; //$NON-NLS-1$ + } + + public String getText() { + return ActionMessages.TerminateAndRelaunchAction_3; + } + + public String getToolTipText() { + return ActionMessages.TerminateAndRelaunchAction_4; + } + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE_AND_RELAUNCH); + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_RELAUNCH); + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_RELAUNCH); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java new file mode 100644 index 000000000..19e9c0408 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.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.internal.ui.commands.actions; + +import org.eclipse.core.runtime.IStatus; +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.IProcess; +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.ITerminateCommand; +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * Terminate and remove action. + * + * @since 3.3 + */ +public class TerminateAndRemoveAction extends DebugCommandAction { + + + class TerminateAndRemoveMonitor extends ActionRequestMonitor { + private Object fElement; + TerminateAndRemoveMonitor(Object element) { + fElement = element; + } + public void done() { + IStatus status = getStatus(); + if(status == null || status.isOK()) { + ILaunch launch= null; + if (fElement instanceof ILaunch) { + launch= (ILaunch) fElement; + } else if (fElement instanceof IDebugElement) { + launch= ((IDebugElement) fElement).getLaunch(); + } else if (fElement instanceof IProcess) { + launch= ((IProcess) fElement).getLaunch(); + } + if (launch != null) + DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch); + } + super.done(); + } + + } + + public String getText() { + return ActionMessages.TerminateAndRemoveAction_0; + } + + public String getHelpContextId() { + return "terminate_and_remove_action_context"; //$NON-NLS-1$ + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.popupMenu.terminateAndRemove"; //$NON-NLS-1$ + } + + public String getToolTipText() { + return ActionMessages.TerminateAndRemoveAction_3; + } + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE_AND_REMOVE); + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_REMOVE); + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_AND_REMOVE); + } + + protected Class getCommandType() { + return ITerminateCommand.class; + } + + protected IAsynchronousRequestMonitor createStatusMonitor(Object target) { + return new TerminateAndRemoveMonitor(target); + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandAction.java new file mode 100644 index 000000000..07528acf4 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandAction.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.ITerminateCommand; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * Terminate action. + * + * @since 3.3 + */ +public class TerminateCommandAction extends DebugCommandAction { + + public TerminateCommandAction() { + setActionDefinitionId("org.eclipse.debug.ui.commands.Terminate"); //$NON-NLS-1$ + } + + public String getText() { + return ActionMessages.TerminateAction_0; + } + + public String getHelpContextId() { + return "terminate_action_context"; //$NON-NLS-1$ + } + + public String getId() { + return "org.eclipse.debug.ui.debugview.toolbar.terminate"; //$NON-NLS-1$ + } + + public String getToolTipText() { + return ActionMessages.TerminateAction_3; + } + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE); + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_TERMINATE); + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_TERMINATE); + } + + protected Class getCommandType() { + return ITerminateCommand.class; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandActionDelegate.java new file mode 100644 index 000000000..a401b2209 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandActionDelegate.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2000, 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.commands.actions; + +/** + * Terminate action delegate. + * + * @since 3.3 + */ +public class TerminateCommandActionDelegate extends DebugCommandActionDelegate { + + public TerminateCommandActionDelegate() { + super(); + setAction(new TerminateCommandAction()); + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersAction.java new file mode 100644 index 000000000..85de71dea --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersAction.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * 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.commands.actions; + +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.internal.ui.commands.provisional.IStepFiltersCommand; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPart; + +public class ToggleStepFiltersAction extends DebugCommandAction { + + public ImageDescriptor getDisabledImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TOGGLE_STEP_FILTERS); + } + + public String getHelpContextId() { + return "step_with_filters_action_context"; //$NON-NLS-1$ + } + + public ImageDescriptor getHoverImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TOGGLE_STEP_FILTERS); + } + + public String getId() { + return "org.eclipse.debug.ui.actions.ToggleStepFilters"; //$NON-NLS-1$ + } + + public ImageDescriptor getImageDescriptor() { + return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TOGGLE_STEP_FILTERS); + } + + public String getText() { + return ActionMessages.ToggleStepFiltersAction_0; + } + + public String getToolTipText() { + return ActionMessages.ToggleStepFiltersAction_0; + } + + protected boolean getInitialEnablement() { + return true; + } + + protected Class getCommandType() { + return IStepFiltersCommand.class; + } + + public void run() { + DebugUITools.setUseStepFilters(!DebugUITools.isUseStepFilters()); + } + + public int getStyle() { + return AS_CHECK_BOX; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.commands.actions.DebugCommandAction#contextActivated(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart, org.eclipse.debug.internal.ui.contexts.IDebugContextService) + */ + public void contextActivated(ISelection context, IWorkbenchPart part) { + if (context.isEmpty()) { + setEnabled(true); + } else { + super.contextActivated(context, part); + } + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersCommandActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersCommandActionDelegate.java new file mode 100644 index 000000000..ad58f05af --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersCommandActionDelegate.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2000, 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.commands.actions; + +/** + * Toggle step filters action delegate. + * + * @since 3.3 + */ +public class ToggleStepFiltersCommandActionDelegate extends DebugCommandActionDelegate { + + public ToggleStepFiltersCommandActionDelegate() { + super(); + setAction(new ToggleStepFiltersAction()); + } + + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IBooleanRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IBooleanRequestMonitor.java new file mode 100644 index 000000000..2618d52d6 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IBooleanRequestMonitor.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.commands.provisional; + +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * Request monitor for obtaining a boolean result asynchronously. + * + * @since 3.3 + */ +public interface IBooleanRequestMonitor extends IAsynchronousRequestMonitor { + + /** + * Sets the result of a boolean request. + * + * @param result the result + */ + public void setResult(boolean result); +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDebugCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDebugCommand.java new file mode 100644 index 000000000..36598bf9c --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDebugCommand.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * 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.commands.provisional; + +import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor; + +/** + * A command that can be enabled or disabled and executed. + * + * @since 3.3 + */ +public interface IDebugCommand { + + /** + * Determines whether this command can be executed on the specified element. + * + * @param element element to operate on + * @param monitor accepts result + */ + public void canExecute(Object element, IBooleanRequestMonitor monitor); + + /** + * Executes this command on the specified element reporting any status + * to the given monitor. + * + * @param element element to perform capability on + * @param monitor status monitor + */ + public void execute(Object element, IAsynchronousRequestMonitor monitor); + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDisconnectCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDisconnectCommand.java new file mode 100644 index 000000000..2e0c03d7f --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDisconnectCommand.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.commands.provisional; + +/** + * Disconnect command. + * + * @since 3.3 + */ +public interface IDisconnectCommand extends IDebugCommand { + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDropToFrameCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDropToFrameCommand.java new file mode 100644 index 000000000..5eae61965 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IDropToFrameCommand.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.commands.provisional; + +/** + * Drop to frame command. + * + * @since 3.3 + */ +public interface IDropToFrameCommand extends IDebugCommand { + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IResumeCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IResumeCommand.java new file mode 100644 index 000000000..2838b9101 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IResumeCommand.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.commands.provisional; + +/** + * Resume command. + * + * @since 3.3 + */ +public interface IResumeCommand extends IDebugCommand { + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepFiltersCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepFiltersCommand.java new file mode 100644 index 000000000..f9bd5b39e --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepFiltersCommand.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.commands.provisional; + +/** + * Step filters command. + * + * @since 3.3 + */ +public interface IStepFiltersCommand extends IDebugCommand { + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepIntoCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepIntoCommand.java new file mode 100644 index 000000000..e797e371c --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepIntoCommand.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.commands.provisional; + +/** + * Step into command. + * + * @since 3.3 + */ +public interface IStepIntoCommand extends IDebugCommand { + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepOverCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepOverCommand.java new file mode 100644 index 000000000..b86dc92a8 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepOverCommand.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.commands.provisional; + +/** + * Step over command. + * + * @since 3.3 + */ +public interface IStepOverCommand extends IDebugCommand { + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepReturnCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepReturnCommand.java new file mode 100644 index 000000000..373ef3ca3 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/IStepReturnCommand.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.commands.provisional; + +/** + * Step return command. + * + * @since 3.3 + */ +public interface IStepReturnCommand extends IDebugCommand { + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/ISuspendCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/ISuspendCommand.java new file mode 100644 index 000000000..3380ba058 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/ISuspendCommand.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.commands.provisional; + +/** + * Suspend command. + * + * @since 3.3 + */ +public interface ISuspendCommand extends IDebugCommand { + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/ITerminateCommand.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/ITerminateCommand.java new file mode 100644 index 000000000..39d0933d8 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/provisional/ITerminateCommand.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.commands.provisional; + +/** + * Terminate command. + * + * @since 3.3 + */ +public interface ITerminateCommand extends IDebugCommand { + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java index 54350b09d..d9b94e94d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.ListenerList; import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener; import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextManager; import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextProvider; +import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextService; import org.eclipse.debug.internal.ui.views.ViewContextManager; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWindowListener; @@ -215,5 +216,12 @@ public class DebugContextManager implements IDebugContextManager { Collection sevices = fServices.values(); return (DebugWindowContextService[]) sevices.toArray(new DebugWindowContextService[sevices.size()]); } + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextManager#getContextService(org.eclipse.ui.IWorkbenchWindow) + */ + public IDebugContextService getContextService(IWorkbenchWindow window) { + return createService(window); + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java index d78d0d434..19781ca16 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java @@ -19,8 +19,11 @@ 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.debug.internal.ui.contexts.provisional.DebugContextEvent; +import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextEventListener; import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener; import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextProvider; +import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextService; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IPartListener2; @@ -34,16 +37,14 @@ import org.eclipse.ui.IWorkbenchWindow; * * @since 3.2 */ -public class DebugWindowContextService implements IDebugContextService, IPartListener2, IDebugContextListener { +public class DebugWindowContextService implements IDebugContextService, IPartListener2, IDebugContextEventListener { private Map fListenersByPartId = new HashMap(); private Map fProvidersByPartId = new HashMap(); + private Map fPostListenersByPartId = new HashMap(); private IWorkbenchWindow fWindow; private List fProviders = new ArrayList(); - - private static final int ACTIVATED = 1; - private static final int CHANGED = 2; public DebugWindowContextService(IWorkbenchWindow window) { fWindow = window; @@ -69,9 +70,9 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis active = activePage.getActivePart(); } if (fProviders.size() == 1 && (part == null || part.equals(active))) { - notify(ACTIVATED); + notify(DebugContextEvent.ACTIVATED); } - provider.addDebugContextListener(this); + provider.addDebugContextEventListener(this); } protected synchronized void removeProvider(IDebugContextProvider provider) { @@ -85,10 +86,10 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis fProvidersByPartId.remove(id); fProviders.remove(index); if (index == 0) { - notify(ACTIVATED); + notify(DebugContextEvent.ACTIVATED); } } - provider.removeDebugContextListener(this); + provider.removeDebugContextEventListener(this); } /* (non-Javadoc) @@ -97,6 +98,30 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis public void addDebugContextListener(IDebugContextListener listener) { addDebugContextListener(listener, null); } + + public void addPostDebugContextListener(IDebugContextListener listener, String partId) { + ListenerList list = (ListenerList) fPostListenersByPartId.get(partId); + if (list == null) { + list = new ListenerList(); + fPostListenersByPartId.put(partId, list); + } + list.add(listener); + } + + public void addPostDebugContextListener(IDebugContextListener listener) { + addPostDebugContextListener(listener, null); + } + + public void removePostDebugContextListener(IDebugContextListener listener, String partId) { + ListenerList list = (ListenerList) fPostListenersByPartId.get(partId); + if (list != null) { + list.remove(listener); + } + } + + public void removePostDebugContextListener(IDebugContextListener listener) { + removePostDebugContextListener(listener, null); + } /* (non-Javadoc) * @see org.eclipse.debug.ui.contexts.IDebugContextService#removeDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener) @@ -119,7 +144,12 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis if (part != null) { notify(type, getListeners(part), context, part); } + notify(type, getPostListeners(null), context, part); + if (part != null) { + notify(type, getPostListeners(part), context, part); + } } + protected void notify(final int type, ListenerList list, final ISelection context, final IWorkbenchPart part) { if (list != null) { Object[] listeners = list.getListeners(); @@ -127,7 +157,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis final IDebugContextListener listener = (IDebugContextListener) listeners[i]; SafeRunner.run(new ISafeRunnable() { public void run() throws Exception { - if (type == ACTIVATED) { + if (type == DebugContextEvent.ACTIVATED) { listener.contextActivated(context, part); } else { listener.contextChanged(context, part); @@ -148,6 +178,14 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis } return (ListenerList) fListenersByPartId.get(id); } + + protected ListenerList getPostListeners(IWorkbenchPart part) { + String id = null; + if (part != null) { + id = part.getSite().getId(); + } + return (ListenerList) fPostListenersByPartId.get(id); + } /* (non-Javadoc) * @see org.eclipse.debug.ui.contexts.IDebugContextService#addDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener, java.lang.String) @@ -202,7 +240,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis if (index > 0) { fProviders.remove(index); fProviders.add(0, provider); - notify(ACTIVATED); + notify(DebugContextEvent.ACTIVATED); } } @@ -251,28 +289,15 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis } /* (non-Javadoc) - * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextActivated(java.lang.Object, org.eclipse.ui.IWorkbenchPart) + * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextEventListener#contextEvent(org.eclipse.debug.internal.ui.contexts.provisional.DebugContextEvent) */ - public synchronized void contextActivated(ISelection context, IWorkbenchPart part) { + public void contextEvent(DebugContextEvent event) { if (!fProviders.isEmpty()) { IDebugContextProvider provider = (IDebugContextProvider) fProviders.get(0); - if (provider.getPart() == part) { - notify(ACTIVATED); + if (provider == event.getDebugContextProvider()) { + notify(event.getEventType()); } - } + } } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.contexts.IDebugContextListener#contextChanged(org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart) - */ - public void contextChanged(ISelection selection, IWorkbenchPart part) { - if (!fProviders.isEmpty()) { - IDebugContextProvider provider = (IDebugContextProvider) fProviders.get(0); - if (provider.getPart() == part) { - notify(CHANGED); - } - } - } - - } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/IDebugContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/IDebugContextService.java deleted file mode 100644 index 7f871ca54..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/IDebugContextService.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * 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.internal.ui.contexts; - -import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener; -import org.eclipse.jface.viewers.ISelection; - - -/** - * Debug context service for a window. - * - * @since 3.2 - */ -public interface IDebugContextService { - - /** - * Registers for context activation notification in this service. - * - * @param listener - */ - public void addDebugContextListener(IDebugContextListener listener); - /** - * Deregisters for context activation notification in this service. - * - * @param listener - */ - public void removeDebugContextListener(IDebugContextListener listener); - - /** - * Registers for context activation notification in the specified part. - * - * @param listener - * @param partId - */ - public void addDebugContextListener(IDebugContextListener listener, String partId); - - /** - * Deregisters for context activation notification in the specified part. - * - * @param listener - * @param partId - */ - public void removeDebugContextListener(IDebugContextListener listener, String partId); - - /** - * Returns the active context in this service's window - * or null. - * - * @return - */ - public ISelection getActiveContext(); - - /** - * Returns the active context in the specified part or null. - * - * @param partId - * @return - */ - public ISelection getActiveContext(String partId); - -} 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. + *

+ * Clients implementing context providers should subclass this class. + *

+ * @since 3.3 + */ +public abstract class AbstractDebugContextProvider implements IDebugContextProvider { + + /** + * Event listeners + */ + private ListenerList fListeners = new ListenerList(); + + /** + * Part or null + */ + private IWorkbenchPart fPart; + + /** + * Constructs a context provider for the specified part, possibly null. + * + * @param part workbench part or null + */ + 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); + } + }); + + } + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/DebugContextEvent.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/DebugContextEvent.java new file mode 100644 index 000000000..a1ebea685 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/DebugContextEvent.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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 java.util.EventObject; + +import org.eclipse.jface.viewers.ISelection; + +/** + * A debug context event. + * + * @since 3.3 + */ +public class DebugContextEvent extends EventObject { + + /** + * The context + */ + private ISelection fContext; + + /** + * Type of context event - change or activation + */ + private int fEventType; + + /** + * Context activation event type. + */ + public static final int ACTIVATED = 1; + + /** + * Context change event type. + */ + public static final int CHANGED = 2; + + /** + * Generated serial version UID for this class. + */ + private static final long serialVersionUID = 3395172504615255524L; + + /** + * @param source + */ + public DebugContextEvent(IDebugContextProvider source, ISelection context, int eventType) { + super(source); + fContext = context; + fEventType = eventType; + } + + /** + * Returns the context associated with this event. + * + * @return + */ + public ISelection getContext() { + return fContext; + } + + /** + * Returns the event type. + * + * @return event type + */ + public int getEventType() { + return fEventType; + } + + /** + * 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/internal/ui/contexts/provisional/IDebugContextEventListener.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextEventListener.java new file mode 100644 index 000000000..a5238fdee --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextEventListener.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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.internal.ui.contexts.provisional; + + +/** + * Notified of context events by a debug context provider. + *

+ * Clients are not intended to implement this interface. + *

+ * @since 3.3 + * @see IDebugContextManager + */ +public interface IDebugContextEventListener { + + /** + * Notification of the specified debug context event. + * + * @param event debug context event + */ + public void contextEvent(DebugContextEvent event); + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextManager.java index 2c3c90a16..02f41bcee 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextManager.java @@ -109,5 +109,14 @@ public interface IDebugContextManager { * * @param listener */ - public void removeDebugContextListener(IDebugContextListener listener); + public void removeDebugContextListener(IDebugContextListener listener); + + /** + * Returns the context service for the specified window. + * + * @param window + * @return context service + * @since 3.3 + */ + public IDebugContextService getContextService(IWorkbenchWindow window); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextProvider.java index fde85fec4..b47a43653 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextProvider.java @@ -32,18 +32,18 @@ public interface IDebugContextProvider { public IWorkbenchPart getPart(); /** - * Registers the given listener for context notifications. + * Registers the given listener for context events. * - * @param listener context listener + * @param listener event listener */ - public void addDebugContextListener(IDebugContextListener listener); + public void addDebugContextEventListener(IDebugContextEventListener listener); /** - * Unregisters the given listener for context notifications. + * Unregisters the given listener for context events. * - * @param listener context listener + * @param listener event listener */ - public void removeDebugContextListener(IDebugContextListener listener); + public void removeDebugContextEventListener(IDebugContextEventListener listener); /** * Returns the currently active context, possibly empty or null. diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextService.java new file mode 100644 index 000000000..a7d7a4706 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/provisional/IDebugContextService.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * 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.internal.ui.contexts.provisional; + +import org.eclipse.jface.viewers.ISelection; + + +/** + * Debug context service for a window. + * + * @since 3.2 + */ +public interface IDebugContextService { + + /** + * Registers for context activation notification in this service. + * + * @param listener + */ + public void addDebugContextListener(IDebugContextListener listener); + /** + * Unregisters for context activation notification in this service. + * + * @param listener + */ + public void removeDebugContextListener(IDebugContextListener listener); + + /** + * Registers for context activation notification in the specified part. + * + * @param listener + * @param partId + */ + public void addDebugContextListener(IDebugContextListener listener, String partId); + + /** + * Unregisters for context activation notification in the specified part. + * + * @param listener + * @param partId + */ + public void removeDebugContextListener(IDebugContextListener listener, String partId); + + /** + * Returns the active context in this service's window + * or null. + * + * @return + */ + public ISelection getActiveContext(); + + /** + * Returns the active context in the specified part or null. + * + * @param partId + * @return + */ + public ISelection getActiveContext(String partId); + + /** + * Registers for post context notification. Post listeners + * are notified of context activation and change after all + * non-post listeners are notified. + * + * @param listener + * @since 3.3 + */ + public void addPostDebugContextListener(IDebugContextListener listener); + /** + * Unregisters for post context notification. + * + * @param listener + * @since 3.3 + */ + public void removePostDebugContextListener(IDebugContextListener listener); + + /** + * Registers for post context notification in the specified part. Post listeners + * are notified of context activation and change after all + * non-post listeners are notified. + * + * @param listener + * @param partId + * @since 3.3 + */ + public void addPostDebugContextListener(IDebugContextListener listener, String partId); + + /** + * Unregisters for post context notification in the specified part. + * + * @param listener + * @param partId + * @since 3.3 + */ + public void removePostDebugContextListener(IDebugContextListener listener, String partId); + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java index bb40e8634..1a1121da8 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousRequestMonitor.java @@ -14,7 +14,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.debug.internal.ui.actions.context.AbstractRequestMonitor; +import org.eclipse.debug.internal.ui.commands.actions.AbstractRequestMonitor; import org.eclipse.ui.progress.WorkbenchJob; /** diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java index 5755ebe7d..5257fb9e5 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java @@ -14,10 +14,7 @@ package org.eclipse.debug.internal.ui.views.launch; import java.util.Iterator; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.SafeRunner; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; @@ -33,21 +30,22 @@ import org.eclipse.debug.internal.ui.IDebugHelpContextIds; import org.eclipse.debug.internal.ui.actions.AddToFavoritesAction; import org.eclipse.debug.internal.ui.actions.EditLaunchConfigurationAction; import org.eclipse.debug.internal.ui.actions.FindElementAction; -import org.eclipse.debug.internal.ui.actions.context.AbstractDebugContextAction; -import org.eclipse.debug.internal.ui.actions.context.DisconnectAction; -import org.eclipse.debug.internal.ui.actions.context.DropToFrameAction; -import org.eclipse.debug.internal.ui.actions.context.ResumeAction; -import org.eclipse.debug.internal.ui.actions.context.StepIntoAction; -import org.eclipse.debug.internal.ui.actions.context.StepOverAction; -import org.eclipse.debug.internal.ui.actions.context.StepReturnAction; -import org.eclipse.debug.internal.ui.actions.context.SuspendAction; -import org.eclipse.debug.internal.ui.actions.context.TerminateAction; -import org.eclipse.debug.internal.ui.actions.context.TerminateAllAction; -import org.eclipse.debug.internal.ui.actions.context.TerminateAndRelaunchAction; -import org.eclipse.debug.internal.ui.actions.context.TerminateAndRemoveAction; +import org.eclipse.debug.internal.ui.commands.actions.DebugCommandAction; +import org.eclipse.debug.internal.ui.commands.actions.DisconnectCommandAction; +import org.eclipse.debug.internal.ui.commands.actions.DropToFrameCommandAction; +import org.eclipse.debug.internal.ui.commands.actions.ResumeCommandAction; +import org.eclipse.debug.internal.ui.commands.actions.StepIntoCommandAction; +import org.eclipse.debug.internal.ui.commands.actions.StepOverCommandAction; +import org.eclipse.debug.internal.ui.commands.actions.StepReturnCommandAction; +import org.eclipse.debug.internal.ui.commands.actions.SuspendCommandAction; +import org.eclipse.debug.internal.ui.commands.actions.TerminateAllAction; +import org.eclipse.debug.internal.ui.commands.actions.TerminateAndRelaunchAction; +import org.eclipse.debug.internal.ui.commands.actions.TerminateAndRemoveAction; +import org.eclipse.debug.internal.ui.commands.actions.TerminateCommandAction; +import org.eclipse.debug.internal.ui.commands.actions.ToggleStepFiltersAction; import org.eclipse.debug.internal.ui.contexts.DebugContextManager; -import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener; -import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextProvider; +import org.eclipse.debug.internal.ui.contexts.provisional.AbstractDebugContextProvider; +import org.eclipse.debug.internal.ui.contexts.provisional.DebugContextEvent; import org.eclipse.debug.internal.ui.sourcelookup.EditSourceLookupPathAction; import org.eclipse.debug.internal.ui.sourcelookup.LookupSourceAction; import org.eclipse.debug.internal.ui.viewers.AsynchronousTreeViewer; @@ -67,7 +65,6 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; @@ -118,6 +115,8 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi private static final String TERMINATE_ALL = "terminate_all"; //$NON-NLS-1$ private static final String TERMINATE_AND_RELAUNCH = "terminate_relaunch"; //$NON-NLS-1$ + + private static final String TOGGLE_STEP_FILTERS = "toggle_step_filters"; //$NON-NLS-1$ /** * Whether this view is in the active page of a perspective. @@ -134,40 +133,19 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi private EditSourceLookupPathAction fEditSourceAction = null; private LookupSourceAction fLookupAction = null; - class ContextProvider implements IDebugContextProvider { - /** - * Context listeners - */ - private ListenerList fListeners = new ListenerList(); + class ContextProvider extends AbstractDebugContextProvider { + public ContextProvider() { + super(LaunchView.this); + // TODO Auto-generated constructor stub + } + private ISelection fContext = null; protected void dispose() { fContext = null; - fListeners.clear(); } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.contexts.IDebugContextProvider#getPart() - */ - public IWorkbenchPart getPart() { - return LaunchView.this; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.contexts.IDebugContextProvider#addDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener) - */ - public void addDebugContextListener(IDebugContextListener listener) { - fListeners.add(listener); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.contexts.IDebugContextProvider#removeDebugContextListener(org.eclipse.debug.ui.contexts.IDebugContextListener) - */ - public void removeDebugContextListener(IDebugContextListener listener) { - fListeners.remove(listener); - } - /* (non-Javadoc) * @see org.eclipse.debug.ui.contexts.IDebugContextProvider#getActiveContext() */ @@ -175,23 +153,11 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi return fContext; } - protected void activate(final ISelection selection) { + protected void activate(ISelection selection) { synchronized (this) { fContext = selection; } - 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.contextActivated(selection, ContextProvider.this.getPart()); - } - public void handleException(Throwable exception) { - DebugUIPlugin.log(exception); - } - }); - - } + fire(new DebugContextEvent(this, selection, DebugContextEvent.ACTIVATED)); } protected void possibleContextChange(Object element) { @@ -205,20 +171,7 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi return; } } - Object[] listeners = fListeners.getListeners(); - final IStructuredSelection context = new StructuredSelection(element); - for (int i = 0; i < listeners.length; i++) { - final IDebugContextListener listener = (IDebugContextListener) listeners[i]; - SafeRunner.run(new ISafeRunnable() { - public void run() throws Exception { - listener.contextChanged(context, ContextProvider.this.getPart()); - } - public void handleException(Throwable exception) { - DebugUIPlugin.log(exception); - } - }); - - } + fire(new DebugContextEvent(this, fContext, DebugContextEvent.CHANGED)); } } @@ -246,43 +199,42 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi fLookupAction = new LookupSourceAction(this); setAction(FIND_ACTION, new FindElementAction(this, (AsynchronousTreeViewer) getViewer())); - - IWorkbenchWindow window = getSite().getWorkbenchWindow(); - TerminateAction terminateAction = new TerminateAction(); - terminateAction.init(window); - setAction(TERMINATE, terminateAction); - DisconnectAction disconnectAction = new DisconnectAction(); - disconnectAction.init(window); - setAction(DISCONNECT, disconnectAction); - SuspendAction suspendAction = new SuspendAction(); - suspendAction.init(window); - setAction(SUSPEND, suspendAction); - ResumeAction resumeAction = new ResumeAction(); - resumeAction.init(window); - setAction(RESUME, resumeAction); - StepReturnAction stepReturnAction = new StepReturnAction(); - stepReturnAction.init(window); - setAction(STEP_RETURN, stepReturnAction); - StepOverAction stepOverAction = new StepOverAction(); - stepOverAction.init(window); - setAction(STEP_OVER, stepOverAction); - StepIntoAction stepIntoAction = new StepIntoAction(); - stepIntoAction.init(window); - setAction(STEP_INTO, stepIntoAction); - DropToFrameAction dropToFrameAction = new DropToFrameAction(); - dropToFrameAction.init(window); - setAction(DROP_TO_FRAME, dropToFrameAction); - TerminateAndRemoveAction terminateAndRemoveAction = new TerminateAndRemoveAction(); - terminateAndRemoveAction.init(window); - setAction(TERMINATE_AND_REMOVE, terminateAndRemoveAction); - TerminateAllAction terminateAll = new TerminateAllAction(); - terminateAll.init(window); - setAction(TERMINATE_ALL, terminateAll); - TerminateAndRelaunchAction terminateAndRelaunchAction = new TerminateAndRelaunchAction(); - terminateAndRelaunchAction.init(window); - setAction(TERMINATE_AND_RELAUNCH, terminateAndRelaunchAction); + addCapabilityAction(new TerminateCommandAction(), TERMINATE); + addCapabilityAction(new DisconnectCommandAction(), DISCONNECT); + addCapabilityAction(new SuspendCommandAction(), SUSPEND); + addCapabilityAction(new ResumeCommandAction(), RESUME); + addCapabilityAction(new StepReturnCommandAction(), STEP_RETURN); + addCapabilityAction(new StepOverCommandAction(), STEP_OVER); + addCapabilityAction(new StepIntoCommandAction(), STEP_INTO); + addCapabilityAction(new DropToFrameCommandAction(), DROP_TO_FRAME); + addCapabilityAction(new TerminateAndRemoveAction(), TERMINATE_AND_REMOVE); + addCapabilityAction(new TerminateAndRelaunchAction(), TERMINATE_AND_RELAUNCH); + addCapabilityAction(new TerminateAllAction(), TERMINATE_ALL); + addCapabilityAction(new ToggleStepFiltersAction(), TOGGLE_STEP_FILTERS); } + + /** + * Initializes the action and associates it with the given id. + * + * @param capability + * @param actionID + */ + private void addCapabilityAction(DebugCommandAction capability, String actionID) { + capability.init(this); + setAction(actionID, capability); + } + + /** + * Disposes the given action. + * + * @param actionID + */ + private void disposeCommandAction(String actionID) { + DebugCommandAction action = (DebugCommandAction) getAction(actionID); + action.dispose(); + } + /* (non-Javadoc) * @see org.eclipse.debug.ui.AbstractDebugView#createViewer(org.eclipse.swt.widgets.Composite) */ @@ -431,6 +383,8 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi tbm.appendToGroup(IDebugUIConstants.STEP_RETURN_GROUP, getAction(STEP_RETURN)); tbm.appendToGroup(IDebugUIConstants.EMPTY_STEP_GROUP, getAction(DROP_TO_FRAME)); + + tbm.appendToGroup(IDebugUIConstants.RENDER_GROUP, getAction(TOGGLE_STEP_FILTERS)); } /* (non-Javadoc) @@ -461,28 +415,17 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi PropertyDialogAction properties = (PropertyDialogAction) getAction("Properties"); //$NON-NLS-1$ properties.dispose(); - AbstractDebugContextAction action = (AbstractDebugContextAction) getAction(TERMINATE); - action.dispose(); - action = (AbstractDebugContextAction) getAction(DISCONNECT); - action.dispose(); - action = (AbstractDebugContextAction) getAction(SUSPEND); - action.dispose(); - action = (AbstractDebugContextAction) getAction(RESUME); - action.dispose(); - action = (AbstractDebugContextAction) getAction(STEP_RETURN); - action.dispose(); - action = (AbstractDebugContextAction) getAction(STEP_OVER); - action.dispose(); - action = (AbstractDebugContextAction) getAction(STEP_INTO); - action.dispose(); - action = (AbstractDebugContextAction) getAction(DROP_TO_FRAME); - action.dispose(); - action = (AbstractDebugContextAction) getAction(TERMINATE_AND_REMOVE); - action.dispose(); - action = (AbstractDebugContextAction) getAction(TERMINATE_ALL); - action.dispose(); - action = (AbstractDebugContextAction) getAction(TERMINATE_AND_RELAUNCH); - action.dispose(); + disposeCommandAction(TERMINATE); + disposeCommandAction(DISCONNECT); + disposeCommandAction(SUSPEND); + disposeCommandAction(RESUME); + disposeCommandAction(STEP_RETURN); + disposeCommandAction(STEP_OVER); + disposeCommandAction(STEP_INTO); + disposeCommandAction(DROP_TO_FRAME); + disposeCommandAction(TERMINATE_AND_REMOVE); + disposeCommandAction(TERMINATE_AND_RELAUNCH); + disposeCommandAction(TERMINATE_ALL); } /** @@ -612,6 +555,8 @@ public class LaunchView extends AbstractDebugView implements ISelectionChangedLi menu.appendToGroup(IDebugUIConstants.STEP_RETURN_GROUP, getAction(STEP_RETURN)); menu.appendToGroup(IDebugUIConstants.EMPTY_STEP_GROUP, getAction(DROP_TO_FRAME)); + + menu.appendToGroup(IDebugUIConstants.RENDER_GROUP, getAction(TOGGLE_STEP_FILTERS)); } /** -- cgit v1.2.3