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

New implementation of the "Load Symbols For All" action of the Shared Libraries view.

Fixes for the "Auto-Refresh" and "refresh" actions.
This commit is contained in:
Mikhail Khodjaiants 2004-06-11 21:49:09 +00:00
parent 181779924b
commit 2d97441a1f
8 changed files with 337 additions and 167 deletions

View file

@ -1,3 +1,14 @@
2004-06-11 Mikhail Khodjaiants
New implementation of the "Load Symbols For All" action of the Shared Libraries view.
Fixes for the "Auto-Refresh" and "refresh" actions.
* AbstractAutoRefreshActionDelegate.java
* AbstractRefreshActionDelegate.java
* LoadSymbolsForAllAction.java: removed
* LoadSymbolsForAllActionDelegate.java: new
* SharedLibrariesView.java
* plugin.properties
* plugin.xml
2004-06-11 Mikhail Khodjaiants
New implementation of the "Auto-Refresh" actions for registers and shared libraries.
* plugin.properties

View file

@ -68,6 +68,8 @@ CDebugEditor.name= C/C++ Debug Editor
LoadSymbolsAction.label=Load Symbols
LoadSymbolsAction.tooltip=Load Shared Library's Symbols
LoadSymbolsForAllAction.label=Load Symbols For All
LoadSymbolsForAllAction.tooltip=Load Symbols For All Shared Libraries
SignalAction.label=Resume With Signal
SignalAction.tooltip=Resume With Signal

View file

@ -550,6 +550,36 @@
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
<action
helpContextId="auto_refresh_shared_libraries_context"
label="%AutoRefreshAction.label"
tooltip="%AutoRefreshAction.tooltip"
icon="icons/full/elcl16/auto_refresh_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.AutoRefreshSharedLibrariesActionDelegate"
style="toggle"
menubarPath="refreshGroup"
id="org.eclipse.cdt.debug.internal.ui.actions.AutoRefreshSharedLibrariesActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
<action
helpContextId="load_symbols_for_all_context"
label="%LoadSymbolsForAllAction.label"
tooltip="%LoadSymbolsForAllAction.tooltip"
icon="icons/full/elcl16/load_all_symbols_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate"
style="push"
menubarPath="sharedLibrariesGroup"
id="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
</viewerContribution>
<objectContribution
objectClass="org.eclipse.cdt.debug.core.model.ICSharedLibrary"
@ -794,6 +824,21 @@
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
<action
helpContextId="auto_refresh_registers_context"
label="%AutoRefreshAction.label"
tooltip="%AutoRefreshAction.tooltip"
icon="icons/full/elcl16/auto_refresh_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.AutoRefreshRegistersActionDelegate"
style="toggle"
menubarPath="refreshGroup"
id="org.eclipse.cdt.debug.internal.ui.actions.AutoRefreshRegistersActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
</viewerContribution>
</extension>
<extension
@ -996,6 +1041,23 @@
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
<action
helpContextId="load_symbols_for_all_context"
disabledIcon="icons/full/dlcl16/load_all_symbols_co.gif"
hoverIcon="icons/full/clcl16/load_all_symbols_co.gif"
toolbarPath="sharedLibrariesGroupLoadSymbolsForAllAction.label"
label="%LoadSymbolsForAllAction.label"
tooltip="%LoadSymbolsForAllAction.tooltip"
icon="icons/full/elcl16/load_all_symbols_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate"
style="push"
id="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
</viewContribution>
<viewContribution
targetID="org.eclipse.debug.ui.RegisterView"

View file

@ -11,83 +11,48 @@
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.ICUpdateManager;
import org.eclipse.debug.ui.IDebugView;
import org.eclipse.debug.core.DebugException;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.jface.viewers.IStructuredSelection;
/**
* The superclass for all "Auto-Refresh" action delegates.
*/
public abstract class AbstractAutoRefreshActionDelegate extends ActionDelegate implements IViewActionDelegate, IUpdate {
private IAction fAction;
private IDebugView fView;
public abstract class AbstractAutoRefreshActionDelegate extends AbstractRefreshActionDelegate {
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractRefreshActionDelegate#doAction()
*/
public void init( IAction action ) {
setAction( action );
super.init( action );
}
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
public void init( IViewPart view ) {
setView( view );
if ( getView() != null ) {
getView().add( this );
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
protected void doAction() throws DebugException {
IAction action = getAction();
if ( getView() != null && action != null ) {
ICUpdateManager um = getUpdateManager( getView().getViewer().getInput() );
action.setEnabled( ( um != null ) ? um.canUpdate() : false );
action.setChecked( ( um != null ) ? um.getAutoModeEnabled() : false );
if ( action != null ) {
IStructuredSelection selection = getSelection();
if ( !selection.isEmpty() ) {
ICUpdateManager um = getUpdateManager( selection.getFirstElement() );
if ( um != null )
um.setAutoModeEnabled( action.isChecked() );
}
}
}
public void run( IAction action ) {
if ( getView() != null ) {
ICUpdateManager um = getUpdateManager( getView().getViewer().getInput() );
if ( um != null )
um.setAutoModeEnabled( action.isChecked() );
}
}
protected IAction getAction() {
return fAction;
}
private void setAction( IAction action ) {
fAction = action;
}
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionDelegate#dispose()
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractRefreshActionDelegate#update()
*/
public void dispose() {
if ( getView() != null )
getView().remove( this );
super.dispose();
protected void update() {
IAction action = getAction();
if ( action != null ) {
boolean enabled = false;
boolean checked = false;
IStructuredSelection selection = getSelection();
if ( !selection.isEmpty() ) {
ICUpdateManager um = getUpdateManager( selection.getFirstElement() );
if ( um != null && um.canUpdate() )
enabled = true;
if ( um != null && um.getAutoModeEnabled() )
checked = true;
}
action.setEnabled( enabled );
action.setChecked( checked );
}
}
protected IDebugView getView() {
return fView;
}
private void setView( IViewPart view ) {
fView = ( view instanceof IDebugView ) ? (IDebugView)view : null;
}
protected abstract ICUpdateManager getUpdateManager( Object element );
}

View file

@ -7,56 +7,80 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.ICUpdateManager;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
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.debug.ui.IDebugView;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.INullSelectionListener;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.ui.texteditor.IUpdate;
/**
* The superclass for all "Refresh" action delegates.
*/
public abstract class AbstractRefreshActionDelegate extends ActionDelegate implements IViewActionDelegate, IUpdate {
public abstract class AbstractRefreshActionDelegate extends ActionDelegate implements IViewActionDelegate, ISelectionListener, INullSelectionListener, IDebugEventSetListener {
private IAction fAction;
private IDebugView fView;
/* (non-Javadoc)
private IStructuredSelection fSelection;
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
public void init( IViewPart view ) {
setView( view );
if ( getView() != null ) {
getView().add( this );
DebugPlugin.getDefault().addDebugEventListener( this );
IWorkbenchWindow window = getWindow();
if ( window != null ) {
window.getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
}
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
*/
public void init( IAction action ) {
setAction( action );
action.setEnabled( false );
super.init( action );
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.actions.ActionDelegate#dispose()
*/
public void dispose() {
if ( getView() != null )
getView().remove( this );
IWorkbenchWindow window = getWindow();
if ( window != null ) {
window.getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
}
DebugPlugin.getDefault().removeDebugEventListener( this );
super.dispose();
}
@ -65,21 +89,12 @@ public abstract class AbstractRefreshActionDelegate extends ActionDelegate imple
}
private void setView( IViewPart view ) {
fView = ( view instanceof IDebugView ) ? (IDebugView)view : null;
fView = (view instanceof IDebugView) ? (IDebugView)view : null;
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
IAction action = getAction();
if ( getView() != null && action != null ) {
ICUpdateManager um = getUpdateManager( getView().getViewer().getInput() );
action.setEnabled( ( um != null ) ? um.canUpdate() : false );
}
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run( IAction action ) {
@ -103,8 +118,7 @@ public abstract class AbstractRefreshActionDelegate extends ActionDelegate imple
else {
DebugUIPlugin.log( ms );
}
}
}
}
protected IAction getAction() {
@ -116,12 +130,93 @@ public abstract class AbstractRefreshActionDelegate extends ActionDelegate imple
}
protected void doAction() throws DebugException {
if ( getView() != null ) {
if ( getView() != null ) {
ICUpdateManager um = getUpdateManager( getView().getViewer().getInput() );
if ( um != null )
um.update();
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
setSelection( selection );
update();
}
private IWorkbenchWindow getWindow() {
if ( getView() != null ) {
return getView().getViewSite().getWorkbenchWindow();
}
return null;
}
protected void update() {
IAction action = getAction();
if ( action != null ) {
boolean enabled = false;
IStructuredSelection selection = getSelection();
if ( !selection.isEmpty() ) {
ICUpdateManager um = getUpdateManager( selection.getFirstElement() );
if ( um != null && um.canUpdate() )
enabled = true;
}
action.setEnabled( enabled );
}
}
protected abstract ICUpdateManager getUpdateManager( Object element );
}
protected IStructuredSelection getSelection() {
return fSelection;
}
private void setSelection( ISelection selection ) {
fSelection = (selection instanceof IStructuredSelection) ? (IStructuredSelection)selection : null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
*/
public void handleDebugEvents( final DebugEvent[] events ) {
if ( getWindow() == null || getAction() == null ) {
return;
}
Shell shell = getWindow().getShell();
if ( shell == null || shell.isDisposed() ) {
return;
}
Runnable r = new Runnable() {
public void run() {
for( int i = 0; i < events.length; i++ ) {
if ( events[i].getSource() != null ) {
doHandleDebugEvent( events[i] );
}
}
}
};
shell.getDisplay().asyncExec( r );
}
protected void doHandleDebugEvent( DebugEvent event ) {
switch( event.getKind() ) {
case DebugEvent.TERMINATE:
update();
break;
case DebugEvent.RESUME:
if ( !event.isEvaluation() || !((event.getDetail() & DebugEvent.EVALUATION_IMPLICIT) != 0) ) {
update();
}
break;
case DebugEvent.SUSPEND:
update();
break;
}
}
}

View file

@ -1,72 +0,0 @@
/*
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.IUpdate;
/**
* Enter type comment.
*
* @since: Feb 11, 2003
*/
public class LoadSymbolsForAllAction extends Action implements IUpdate {
private Viewer fViewer = null;
/**
* Constructor for LoadSymbolsForAllAction.
*/
public LoadSymbolsForAllAction( Viewer viewer ) {
super( ActionMessages.getString( "LoadSymbolsForAllAction.Load_Symbols_For_All_1" ) ); //$NON-NLS-1$
fViewer = viewer;
// CDebugImages.setLocalImageDescriptors( this, ICDebugUIConstants.IMG_LCL_LOAD_ALL_SYMBOLS );
setDescription( ActionMessages.getString( "LoadSymbolsForAllAction.Load_symbols_for_all_shared_libraries_1" ) ); //$NON-NLS-1$
setToolTipText( ActionMessages.getString( "LoadSymbolsForAllAction.Load_Symbols_For_All_2" ) ); //$NON-NLS-1$
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.LOAD_SYMBOLS_FOR_ALL );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
if ( fViewer != null && fViewer.getInput() instanceof IAdaptable ) {
ICDebugTarget target = (ICDebugTarget)((IAdaptable)fViewer.getInput()).getAdapter(ICDebugTarget.class);
if ( target != null ) {
setEnabled( target.isSuspended() );
return;
}
}
setEnabled( false );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
if ( fViewer != null && fViewer.getInput() instanceof IAdaptable ) {
ICDebugTarget target = (ICDebugTarget)((IAdaptable)fViewer.getInput()).getAdapter(ICDebugTarget.class);
if ( target != null ) {
try {
target.loadSymbols();
}
catch( DebugException e ) {
CDebugUIPlugin.errorDialog( ActionMessages.getString( "LoadSymbolsForAllAction.Unable_to_load_symbols_1" ), e.getStatus() ); //$NON-NLS-1$
}
}
}
}
}

View file

@ -0,0 +1,104 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems 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:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.ui.IDebugView;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.ui.texteditor.IUpdate;
/**
* A delegate for the "Load Symbols For All" action of the Shared Libraries view.
*/
public class LoadSymbolsForAllActionDelegate extends ActionDelegate implements IViewActionDelegate, IUpdate {
private IAction fAction;
private IDebugView fView;
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
public void init( IViewPart view ) {
setView( view );
if ( getView() != null ) {
getView().add( this );
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
*/
public void init( IAction action ) {
setAction( action );
super.init( action );
}
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionDelegate#dispose()
*/
public void dispose() {
if ( getView() != null )
getView().remove( this );
super.dispose();
}
protected IDebugView getView() {
return fView;
}
private void setView( IViewPart view ) {
fView = ( view instanceof IDebugView ) ? (IDebugView)view : null;
}
protected IAction getAction() {
return fAction;
}
private void setAction( IAction action ) {
fAction = action;
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IUpdate#update()
*/
public void update() {
IAction action = getAction();
if ( getView() != null && action != null ) {
ICDebugTarget target = getDebugTarget( getView().getViewer().getInput() );
action.setEnabled( ( target != null ) ? target.isSuspended() : false );
}
}
private ICDebugTarget getDebugTarget( Object element ) {
if ( element instanceof IDebugElement ) {
return (ICDebugTarget)((IDebugElement)element).getDebugTarget().getAdapter( ICDebugTarget.class );
}
return null;
}
public void run( IAction action ) {
ICDebugTarget target = getDebugTarget( getView().getViewer().getInput() );
if ( target != null ) {
try {
target.loadSymbols();
}
catch( DebugException e ) {
DebugUIPlugin.errorDialog( getView().getSite().getShell(), "Error", "Operation failed.", e.getStatus() );
}
}
}
}

View file

@ -156,6 +156,8 @@ public class SharedLibrariesView extends AbstractDebugEventHandlerView
* @see org.eclipse.debug.ui.AbstractDebugView#fillContextMenu(IMenuManager)
*/
protected void fillContextMenu( IMenuManager menu ) {
menu.add( new Separator( ICDebugUIConstants.EMPTY_SHARED_LIBRARIES_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.SHARED_LIBRARIES_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.EMPTY_REFRESH_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.REFRESH_GROUP ) );
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
@ -166,6 +168,7 @@ public class SharedLibrariesView extends AbstractDebugEventHandlerView
* @see org.eclipse.debug.ui.AbstractDebugView#configureToolBar(IToolBarManager)
*/
protected void configureToolBar( IToolBarManager tbm ) {
tbm.add( new Separator( ICDebugUIConstants.SHARED_LIBRARIES_GROUP ) );
tbm.add( new Separator( ICDebugUIConstants.REFRESH_GROUP ) );
}