1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Applied the changes made to the corresponding classes of 'org.eclipse.debug.ui'.

This commit is contained in:
Mikhail Khodjaiants 2003-10-31 20:52:21 +00:00
parent b33778110f
commit 4d9be4fde4
7 changed files with 71 additions and 161 deletions

View file

@ -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 2003-10-28 Mikhail Khodjaiants
Changed name of source lookup preference page. Changed name of source lookup preference page.
* plugin.properties * plugin.properties

View file

@ -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; package org.eclipse.cdt.debug.internal.ui.actions;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.core.runtime.MultiStatus; 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.jface.viewers.StructuredSelection;
import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.INullSelectionListener;
import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewPart;
@ -25,7 +31,7 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate; 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 * 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.
* <p>
* AbstractDebugActionDelegates come in 2 flavors: IViewActionDelegate, * AbstractDebugActionDelegates come in 2 flavors: IViewActionDelegate,
* IWorkbenchWindowActionDelegate delegates. * IWorkbenchWindowActionDelegate delegates.
* </p> * </p>
@ -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. * Performs the specific action on this element.
*/ */
protected abstract void doAction(Object element) throws DebugException; 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 * Returns the String to use as an error dialog title for
* a failed action. Default is to return null. * a failed action. Default is to return null.
@ -328,4 +295,25 @@ public abstract class AbstractDebugActionDelegate implements IWorkbenchWindowAct
protected void setWindow(IWorkbenchWindow window) { protected void setWindow(IWorkbenchWindow window) {
fWindow = window; fWindow = window;
} }
/**
* 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;
}
} }

View file

@ -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; 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.DebugEvent;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IDebugEventSetListener; import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.jface.action.IAction;
import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.swt.widgets.Event;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IPageListener; import org.eclipse.ui.IActionDelegate2;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow; 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) * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/ * @see org.eclipse.ui.IActionDelegate2#dispose()
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()
*/ */
public void dispose() { public void dispose() {
super.dispose(); super.dispose();
DebugPlugin.getDefault().removeDebugEventListener(this); DebugPlugin.getDefault().removeDebugEventListener(this);
getWindow().removePageListener(this);
if (getView() != null) {
getView().getViewSite().getPage().removePartListener(this);
}
} }
/** /**
* @see IDebugEventSetListener#handleDebugEvents(DebugEvent[]) * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[])
*/ */
public void handleDebugEvents(final DebugEvent[] events) { public void handleDebugEvents(final DebugEvent[] events) {
if (getPage() == null || getAction() == null) { if (getWindow() == null || getAction() == null) {
return; return;
} }
Shell shell= getWindow().getShell(); Shell shell= getWindow().getShell();
@ -91,22 +56,7 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction
} }
}; };
getPage().getWorkbenchWindow().getShell().getDisplay().asyncExec(r); shell.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;
} }
/** /**
@ -137,7 +87,6 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction
public void init(IWorkbenchWindow window){ public void init(IWorkbenchWindow window){
super.init(window); super.init(window);
DebugPlugin.getDefault().addDebugEventListener(this); DebugPlugin.getDefault().addDebugEventListener(this);
window.addPageListener(this);
} }
/** /**
@ -147,46 +96,18 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction
super.init(view); super.init(view);
DebugPlugin.getDefault().addDebugEventListener(this); DebugPlugin.getDefault().addDebugEventListener(this);
setWindow(view.getViewSite().getWorkbenchWindow()); setWindow(view.getViewSite().getWorkbenchWindow());
if ( getPage() != null )
{
getPage().addPartListener(this);
getPage().getWorkbenchWindow().addPageListener(this);
}
} }
/** /**
* @see IPageListener#pageActivated(IWorkbenchPage) * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
*/ */
public void pageActivated(IWorkbenchPage page) { public void init(IAction action) {
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#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
*/ */
public void pageClosed(IWorkbenchPage page) { public void runWithEvent(IAction action, Event event) {
if (page.equals(getPage())) { run(action);
dispose();
}
}
/**
* @see IPageListener#pageOpened(IWorkbenchPage)
*/
public void pageOpened(IWorkbenchPage page) {
} }
} }

View file

@ -63,7 +63,7 @@ public class AddAddressBreakpointActionDelegate extends AbstractListenerActionDe
*/ */
protected void doAction( Object element ) throws DebugException protected void doAction( Object element ) throws DebugException
{ {
InputDialog dialog = new InputDialog( getPage().getWorkbenchWindow().getShell(), InputDialog dialog = new InputDialog( getWindow().getShell(),
"Add Address Breakpoint", "Add Address Breakpoint",
"Enter address:", "Enter address:",
null, null,

View file

@ -30,12 +30,12 @@ public class DebuggerConsoleActionDelegate extends AbstractListenerActionDelegat
*/ */
protected void doAction( Object element ) throws DebugException 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 ); IDebuggerProcessSupport dps = (IDebuggerProcessSupport)((CDebugElement)element).getDebugTarget().getAdapter( IDebuggerProcessSupport.class );
if ( dps != null && dps.supportsDebuggerProcess() ) if ( dps != null && dps.supportsDebuggerProcess() )
{ {
dps.setDebuggerProcessDefault( !dps.isDebuggerProcessDefault() ); dps.setDebuggerProcessDefault( getAction().isChecked() );
((CDebugElement)element).fireChangeEvent( DebugEvent.CLIENT_REQUEST ); ((CDebugElement)element).fireChangeEvent( DebugEvent.CLIENT_REQUEST );
if ( fViewPart != null && fViewPart instanceof AbstractDebugView ) if ( fViewPart != null && fViewPart instanceof AbstractDebugView )
{ {

View file

@ -38,14 +38,6 @@ public class SignalZeroWorkbenchActionDelegate extends AbstractListenerActionDel
return false; return false;
} }
/**
* @see AbstractDebugActionDelegate#enableForMultiSelection()
*/
protected boolean enableForMultiSelection()
{
return false;
}
/** /**
* @see AbstractDebugActionDelegate#getStatusMessage() * @see AbstractDebugActionDelegate#getStatusMessage()
*/ */

View file

@ -31,12 +31,12 @@ public class SwitchToDisassemblyActionDelegate extends AbstractListenerActionDel
*/ */
protected void doAction( Object element ) throws DebugException 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 ); ISourceMode sourceMode = (ISourceMode)((CDebugElement)element).getDebugTarget().getAdapter( ISourceMode.class );
if ( sourceMode != null ) 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 ); ((CDebugElement)element).fireChangeEvent( DebugEvent.CLIENT_REQUEST );
if ( fViewPart != null && fViewPart instanceof ISelectionChangedListener ) if ( fViewPart != null && fViewPart instanceof ISelectionChangedListener )
{ {