From 4d9be4fde44d7fe6f3b39c42c2c229a265ec82f2 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 31 Oct 2003 20:52:21 +0000 Subject: [PATCH] Applied the changes made to the corresponding classes of 'org.eclipse.debug.ui'. --- debug/org.eclipse.cdt.debug.ui/ChangeLog | 9 ++ .../actions/AbstractDebugActionDelegate.java | 80 +++++------ .../AbstractListenerActionDelegate.java | 125 ++++-------------- .../AddAddressBreakpointActionDelegate.java | 2 +- .../DebuggerConsoleActionDelegate.java | 4 +- .../SignalZeroWorkbenchActionDelegate.java | 8 -- .../SwitchToDisassemblyActionDelegate.java | 4 +- 7 files changed, 71 insertions(+), 161 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 446df3d1287..305b9bf260c 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,12 @@ +2003-10-31 Mikhail Khodjaiants + Applied the changes made to the corresponding classes of 'org.eclipse.debug.ui'. + * AbstractDebugActionDelegate.java + * AbstractListenerActionDelegate.java + * AddAddressBreakpointActionDelegate.java + * DebuggerConsoleActionDelegate.java + * SwitchToDisassemblyActionDelegate.java + * SignalZeroWorkbenchActionDelegate.java + 2003-10-28 Mikhail Khodjaiants Changed name of source lookup preference page. * plugin.properties diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractDebugActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractDebugActionDelegate.java index 9769e3a3d14..1823b407e5d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractDebugActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractDebugActionDelegate.java @@ -1,10 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; -/* - * (c) Copyright IBM Corp. 2000, 2001. - * All Rights Reserved. - */ - import java.util.Iterator; import org.eclipse.core.runtime.MultiStatus; @@ -17,6 +22,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.INullSelectionListener; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; @@ -25,7 +31,7 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; -public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowActionDelegate, IViewActionDelegate, ISelectionListener { +public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowActionDelegate, IViewActionDelegate, ISelectionListener, INullSelectionListener { /** * The underlying action for this delegate @@ -112,10 +118,6 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct } /** - * Set the icons for this action on the first selection changed - * event. This is necessary because the XML currently only - * supports setting the enabled icon. - *

* AbstractDebugActionDelegates come in 2 flavors: IViewActionDelegate, * IWorkbenchWindowActionDelegate delegates. *

@@ -153,46 +155,11 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct } } - /** - * Return whether the action should be enabled or not based on the given selection. - */ - protected boolean getEnableStateForSelection(IStructuredSelection selection) { - if (selection.size() == 0) { - return false; - } - Iterator enum= selection.iterator(); - int count= 0; - while (enum.hasNext()) { - count++; - if (count > 1 && !enableForMultiSelection()) { - return false; - } - Object element= enum.next(); - if (!isEnabledFor(element)) { - return false; - } - } - return true; - } - - /** - * Returns whether this action should be enabled if there is - * multi selection. - */ - protected boolean enableForMultiSelection() { - return true; - } - /** * Performs the specific action on this element. */ protected abstract void doAction(Object element) throws DebugException; - /** - * Returns whether this action will work for the given element - */ - protected abstract boolean isEnabledFor(Object element); - /** * Returns the String to use as an error dialog title for * a failed action. Default is to return null. @@ -328,4 +295,25 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct protected void setWindow(IWorkbenchWindow window) { fWindow = window; } -} \ No newline at end of file + + /** + * Return whether the action should be enabled or not based on the given selection. + */ + protected boolean getEnableStateForSelection(IStructuredSelection selection) { + if (selection.size() == 0) { + return false; + } + Iterator enum= selection.iterator(); + while (enum.hasNext()) { + Object element= enum.next(); + if (!isEnabledFor(element)) { + return false; + } + } + return true; + } + + protected boolean isEnabledFor(Object element) { + return true; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractListenerActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractListenerActionDelegate.java index 1c6e0eda830..1f391967a5b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractListenerActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractListenerActionDelegate.java @@ -1,76 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; - -/* - * (c) Copyright IBM Corp. 2002. - * All Rights Reserved. - */ import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IDebugEventSetListener; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.action.IAction; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IPageListener; -import org.eclipse.ui.IPartListener; +import org.eclipse.ui.IActionDelegate2; import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; -public abstract class AbstractListenerActionDelegate extends AbstractDebugActionDelegate implements IDebugEventSetListener, IPartListener, IPageListener { +public abstract class AbstractListenerActionDelegate extends AbstractDebugActionDelegate implements IDebugEventSetListener, IActionDelegate2 { /** - * @see IPartListener#partActivated(IWorkbenchPart) - */ - public void partActivated(IWorkbenchPart part) { - } - - /** - * @see IPartListener#partBroughtToTop(IWorkbenchPart) - */ - public void partBroughtToTop(IWorkbenchPart part) { - } - - /** - * @see IPartListener#partClosed(IWorkbenchPart) - */ - public void partClosed(IWorkbenchPart part) { - if (part.equals(getView())) { - dispose(); - } - } - - /** - * @see IPartListener#partDeactivated(IWorkbenchPart) - */ - public void partDeactivated(IWorkbenchPart part) { - } - - /** - * @see IPartListener#partOpened(IWorkbenchPart) - */ - public void partOpened(IWorkbenchPart part) { - } - - /** - * @see IWorkbenchWindowActionDelegate#dispose() + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + * @see org.eclipse.ui.IActionDelegate2#dispose() */ public void dispose() { super.dispose(); DebugPlugin.getDefault().removeDebugEventListener(this); - getWindow().removePageListener(this); - if (getView() != null) { - getView().getViewSite().getPage().removePartListener(this); - } } /** * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[]) */ public void handleDebugEvents(final DebugEvent[] events) { - if (getPage() == null || getAction() == null) { + if (getWindow() == null || getAction() == null) { return; } Shell shell= getWindow().getShell(); @@ -91,22 +56,7 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction } }; - getPage().getWorkbenchWindow().getShell().getDisplay().asyncExec(r); - } - - /** - * Returns the page that this action works in. - */ - protected IWorkbenchPage getPage() { - if (getWindow() != null) { - return getWindow().getActivePage(); - } else { - IWorkbenchWindow window= DebugUIPlugin.getActiveWorkbenchWindow(); - if (window != null) { - return window.getActivePage(); - } - } - return null; + shell.getDisplay().asyncExec(r); } /** @@ -137,7 +87,6 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction public void init(IWorkbenchWindow window){ super.init(window); DebugPlugin.getDefault().addDebugEventListener(this); - window.addPageListener(this); } /** @@ -147,46 +96,18 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction super.init(view); DebugPlugin.getDefault().addDebugEventListener(this); setWindow(view.getViewSite().getWorkbenchWindow()); - if ( getPage() != null ) - { - getPage().addPartListener(this); - getPage().getWorkbenchWindow().addPageListener(this); - } - } - - /** - * @see IPageListener#pageActivated(IWorkbenchPage) - */ - public void pageActivated(IWorkbenchPage page) { - if (getAction() != null && getView() != null && getPage() != null && getPage().equals(page)) { - Runnable r= new Runnable() { - public void run() { - if (getPage() != null) { - IWorkbenchWindow window= getPage().getWorkbenchWindow(); - if (window != null && window.getShell() != null && !window.getShell().isDisposed()) { - ISelection selection= getPage().getSelection(IDebugUIConstants.ID_DEBUG_VIEW); - update(getAction(), selection); - } - } - } - }; - - getPage().getWorkbenchWindow().getShell().getDisplay().asyncExec(r); - } } /** - * @see IPageListener#pageClosed(IWorkbenchPage) + * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) */ - public void pageClosed(IWorkbenchPage page) { - if (page.equals(getPage())) { - dispose(); - } + public void init(IAction action) { } /** - * @see IPageListener#pageOpened(IWorkbenchPage) + * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event) */ - public void pageOpened(IWorkbenchPage page) { + public void runWithEvent(IAction action, Event event) { + run(action); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddAddressBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddAddressBreakpointActionDelegate.java index 96737064d19..a7bc28be279 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddAddressBreakpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddAddressBreakpointActionDelegate.java @@ -63,7 +63,7 @@ public class AddAddressBreakpointActionDelegate extends AbstractListenerActionDe */ protected void doAction( Object element ) throws DebugException { - InputDialog dialog = new InputDialog( getPage().getWorkbenchWindow().getShell(), + InputDialog dialog = new InputDialog( getWindow().getShell(), "Add Address Breakpoint", "Enter address:", null, diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/DebuggerConsoleActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/DebuggerConsoleActionDelegate.java index 252dfdf93cc..dbacb4264e6 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/DebuggerConsoleActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/DebuggerConsoleActionDelegate.java @@ -30,12 +30,12 @@ public class DebuggerConsoleActionDelegate extends AbstractListenerActionDelegat */ protected void doAction( Object element ) throws DebugException { - if ( element != null && element instanceof CDebugElement ) + if ( element != null && element instanceof CDebugElement && getAction() != null && getAction().isEnabled() ) { IDebuggerProcessSupport dps = (IDebuggerProcessSupport)((CDebugElement)element).getDebugTarget().getAdapter( IDebuggerProcessSupport.class ); if ( dps != null && dps.supportsDebuggerProcess() ) { - dps.setDebuggerProcessDefault( !dps.isDebuggerProcessDefault() ); + dps.setDebuggerProcessDefault( getAction().isChecked() ); ((CDebugElement)element).fireChangeEvent( DebugEvent.CLIENT_REQUEST ); if ( fViewPart != null && fViewPart instanceof AbstractDebugView ) { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalZeroWorkbenchActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalZeroWorkbenchActionDelegate.java index 2ba5d98a516..580650284c8 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalZeroWorkbenchActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SignalZeroWorkbenchActionDelegate.java @@ -38,14 +38,6 @@ public class SignalZeroWorkbenchActionDelegate extends AbstractListenerActionDel return false; } - /** - * @see AbstractDebugActionDelegate#enableForMultiSelection() - */ - protected boolean enableForMultiSelection() - { - return false; - } - /** * @see AbstractDebugActionDelegate#getStatusMessage() */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SwitchToDisassemblyActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SwitchToDisassemblyActionDelegate.java index beb99fb5085..9e8cfa2f30c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SwitchToDisassemblyActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/SwitchToDisassemblyActionDelegate.java @@ -31,12 +31,12 @@ public class SwitchToDisassemblyActionDelegate extends AbstractListenerActionDel */ protected void doAction( Object element ) throws DebugException { - if ( element != null && element instanceof CDebugElement ) + if ( element != null && element instanceof CDebugElement && getAction() != null && getAction().isEnabled() ) { ISourceMode sourceMode = (ISourceMode)((CDebugElement)element).getDebugTarget().getAdapter( ISourceMode.class ); if ( sourceMode != null ) { - sourceMode.setMode( ( sourceMode.getMode() == ISourceMode.MODE_SOURCE ) ? ISourceMode.MODE_DISASSEMBLY : ISourceMode.MODE_SOURCE ); + sourceMode.setMode( ( getAction().isChecked() ) ? ISourceMode.MODE_DISASSEMBLY : ISourceMode.MODE_SOURCE ); ((CDebugElement)element).fireChangeEvent( DebugEvent.CLIENT_REQUEST ); if ( fViewPart != null && fViewPart instanceof ISelectionChangedListener ) {