mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 04:45:38 +02:00
Added the superclass for action delegates of views different than the Debug view and driven by the selection in the Debug view.
All "Auto-refresh" actions implement "Observer" to be notified of changes by the corresponding update managers.
This commit is contained in:
parent
1539cf8919
commit
e5e1f62891
8 changed files with 310 additions and 229 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2004-06-12 Mikhail Khodjaiants
|
||||||
|
Added the superclass for action delegates of views different than the Debug view and
|
||||||
|
driven by the selection in the Debug view.
|
||||||
|
All "Auto-refresh" actions implement "Observer" to be notified of changes
|
||||||
|
by the corresponding update managers.
|
||||||
|
* ActionMessages.properties
|
||||||
|
* AbstractAutoRefreshActionDelegate.java
|
||||||
|
* AbstractRefreshActionDelegate.java
|
||||||
|
* AbstractViewActionDelegate.java: new
|
||||||
|
* LoadSymbolsForAllActionDelegate.java
|
||||||
|
* RefreshRegistersAction.java
|
||||||
|
* RefreshSharedLibrariesAction.java
|
||||||
|
|
||||||
2004-06-11 Mikhail Khodjaiants
|
2004-06-11 Mikhail Khodjaiants
|
||||||
New implementation of the "Load Symbols For All" action of the Shared Libraries view.
|
New implementation of the "Load Symbols For All" action of the Shared Libraries view.
|
||||||
Fixes for the "Auto-Refresh" and "refresh" actions.
|
Fixes for the "Auto-Refresh" and "refresh" actions.
|
||||||
|
|
|
@ -10,15 +10,19 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
|
import java.util.Observable;
|
||||||
|
import java.util.Observer;
|
||||||
import org.eclipse.cdt.debug.core.ICUpdateManager;
|
import org.eclipse.cdt.debug.core.ICUpdateManager;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The superclass for all "Auto-Refresh" action delegates.
|
* The superclass for all "Auto-Refresh" action delegates.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractAutoRefreshActionDelegate extends AbstractRefreshActionDelegate {
|
public abstract class AbstractAutoRefreshActionDelegate extends AbstractRefreshActionDelegate implements Observer{
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractRefreshActionDelegate#doAction()
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractRefreshActionDelegate#doAction()
|
||||||
|
@ -55,4 +59,46 @@ public abstract class AbstractAutoRefreshActionDelegate extends AbstractRefreshA
|
||||||
action.setChecked( checked );
|
action.setChecked( checked );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
|
||||||
|
*/
|
||||||
|
public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
|
||||||
|
IStructuredSelection ss = getSelection();
|
||||||
|
if ( !ss.isEmpty() ) {
|
||||||
|
ICUpdateManager um = getUpdateManager( ss.getFirstElement() );
|
||||||
|
if ( um instanceof Observable ) {
|
||||||
|
((Observable)um).deleteObserver( this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.selectionChanged( part, selection );
|
||||||
|
ss = getSelection();
|
||||||
|
if ( !ss.isEmpty() ) {
|
||||||
|
ICUpdateManager um = getUpdateManager( ss.getFirstElement() );
|
||||||
|
if ( um instanceof Observable ) {
|
||||||
|
((Observable)um).addObserver( this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IActionDelegate2#dispose()
|
||||||
|
*/
|
||||||
|
public void dispose() {
|
||||||
|
IStructuredSelection ss = getSelection();
|
||||||
|
if ( !ss.isEmpty() ) {
|
||||||
|
ICUpdateManager um = getUpdateManager( ss.getFirstElement() );
|
||||||
|
if ( um instanceof Observable ) {
|
||||||
|
((Observable)um).deleteObserver( this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void update( Observable o, Object arg ) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,134 +1,43 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Copyright (c) 2004 QNX Software Systems and others.
|
* Copyright (c) 2004 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* are made available under the terms of the Common Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* 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.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.DebugEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
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.action.IAction;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The superclass for all "Refresh" action delegates.
|
* The superclass for all "Refresh" action delegates.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractRefreshActionDelegate extends ActionDelegate implements IViewActionDelegate, ISelectionListener, INullSelectionListener, IDebugEventSetListener {
|
public abstract class AbstractRefreshActionDelegate extends AbstractViewActionDelegate {
|
||||||
|
|
||||||
private IAction fAction;
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#getErrorDialogTitle()
|
||||||
private IDebugView fView;
|
|
||||||
|
|
||||||
private IStructuredSelection fSelection;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
|
|
||||||
*/
|
*/
|
||||||
public void init( IViewPart view ) {
|
protected String getErrorDialogTitle() {
|
||||||
setView( view );
|
return ActionMessages.getString( "AbstractRefreshActionDelegate.Error_1" ); //$NON-NLS-1$
|
||||||
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.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#getErrorDialogMessage()
|
||||||
*
|
|
||||||
* @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
|
|
||||||
*/
|
*/
|
||||||
public void init( IAction action ) {
|
protected String getErrorDialogMessage() {
|
||||||
setAction( action );
|
return ActionMessages.getString( "AbstractRefreshActionDelegate.Error(s)_occurred_refreshing_the_view_1" ); //$NON-NLS-1$
|
||||||
action.setEnabled( false );
|
|
||||||
super.init( action );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* (non-Javadoc)
|
||||||
* (non-Javadoc)
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doAction()
|
||||||
*
|
|
||||||
* @see org.eclipse.ui.actions.ActionDelegate#dispose()
|
|
||||||
*/
|
*/
|
||||||
public void dispose() {
|
|
||||||
IWorkbenchWindow window = getWindow();
|
|
||||||
if ( window != null ) {
|
|
||||||
window.getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
|
||||||
}
|
|
||||||
DebugPlugin.getDefault().removeDebugEventListener( this );
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IDebugView getView() {
|
|
||||||
return fView;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setView( IViewPart view ) {
|
|
||||||
fView = (view instanceof IDebugView) ? (IDebugView)view : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
|
||||||
*/
|
|
||||||
public void run( IAction action ) {
|
|
||||||
final MultiStatus ms = new MultiStatus( CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, "", null ); //$NON-NLS-1$
|
|
||||||
BusyIndicator.showWhile( Display.getCurrent(), new Runnable() {
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
doAction();
|
|
||||||
}
|
|
||||||
catch( DebugException e ) {
|
|
||||||
ms.merge( e.getStatus() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
if ( !ms.isOK() ) {
|
|
||||||
IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
|
|
||||||
if ( window != null ) {
|
|
||||||
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString( "internal.ui.actions.RefreshAction.Unable_to_refresh" ), ms.getChildren()[0] ); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
DebugUIPlugin.log( ms );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IAction getAction() {
|
|
||||||
return fAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setAction( IAction action ) {
|
|
||||||
fAction = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void doAction() throws DebugException {
|
protected void doAction() throws DebugException {
|
||||||
if ( getView() != null ) {
|
if ( getView() != null ) {
|
||||||
ICUpdateManager um = getUpdateManager( getView().getViewer().getInput() );
|
ICUpdateManager um = getUpdateManager( getView().getViewer().getInput() );
|
||||||
|
@ -137,23 +46,9 @@ public abstract class AbstractRefreshActionDelegate extends ActionDelegate imple
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* (non-Javadoc)
|
||||||
* (non-Javadoc)
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#update()
|
||||||
*
|
|
||||||
* @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() {
|
protected void update() {
|
||||||
IAction action = getAction();
|
IAction action = getAction();
|
||||||
if ( action != null ) {
|
if ( action != null ) {
|
||||||
|
@ -168,42 +63,9 @@ public abstract class AbstractRefreshActionDelegate extends ActionDelegate imple
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract ICUpdateManager getUpdateManager( Object element );
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doHandleDebugEvent(org.eclipse.debug.core.DebugEvent)
|
||||||
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 ) {
|
protected void doHandleDebugEvent( DebugEvent event ) {
|
||||||
switch( event.getKind() ) {
|
switch( event.getKind() ) {
|
||||||
case DebugEvent.TERMINATE:
|
case DebugEvent.TERMINATE:
|
||||||
|
@ -219,4 +81,6 @@ public abstract class AbstractRefreshActionDelegate extends ActionDelegate imple
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
protected abstract ICUpdateManager getUpdateManager( Object element );
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,187 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* 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.ui.CDebugUIPlugin;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
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.DebugUITools;
|
||||||
|
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.jface.viewers.StructuredSelection;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The superclass for action delegates of views different than the Debug view and
|
||||||
|
* driven by the selection in the Debug view.
|
||||||
|
*/
|
||||||
|
public abstract class AbstractViewActionDelegate extends ActionDelegate implements IViewActionDelegate, ISelectionListener, INullSelectionListener, IDebugEventSetListener {
|
||||||
|
|
||||||
|
private IAction fAction;
|
||||||
|
|
||||||
|
private IDebugView fView;
|
||||||
|
|
||||||
|
private IStructuredSelection fSelection = StructuredSelection.EMPTY;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
|
||||||
|
*/
|
||||||
|
public void init( IViewPart view ) {
|
||||||
|
setView( view );
|
||||||
|
DebugPlugin.getDefault().addDebugEventListener( this );
|
||||||
|
IWorkbenchWindow window = getWindow();
|
||||||
|
if ( window != null ) {
|
||||||
|
window.getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||||
|
}
|
||||||
|
IAdaptable context = DebugUITools.getDebugContext();
|
||||||
|
IStructuredSelection ss = ( context != null ) ? new StructuredSelection( context ) : StructuredSelection.EMPTY;
|
||||||
|
selectionChanged( (IWorkbenchPart)null, ss );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IActionDelegate2#dispose()
|
||||||
|
*/
|
||||||
|
public void dispose() {
|
||||||
|
IWorkbenchWindow window = getWindow();
|
||||||
|
if ( window != null ) {
|
||||||
|
window.getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||||
|
}
|
||||||
|
DebugPlugin.getDefault().removeDebugEventListener( this );
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
|
||||||
|
*/
|
||||||
|
public void init( IAction action ) {
|
||||||
|
setAction( action );
|
||||||
|
action.setEnabled( false );
|
||||||
|
super.init( action );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IDebugView getView() {
|
||||||
|
return fView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setView( IViewPart view ) {
|
||||||
|
fView = (view instanceof IDebugView) ? (IDebugView)view : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||||
|
*/
|
||||||
|
public void run( IAction action ) {
|
||||||
|
final MultiStatus ms = new MultiStatus( CDebugUIPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, "", null ); //$NON-NLS-1$
|
||||||
|
BusyIndicator.showWhile( Display.getCurrent(), new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
doAction();
|
||||||
|
}
|
||||||
|
catch( DebugException e ) {
|
||||||
|
ms.merge( e.getStatus() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
if ( !ms.isOK() ) {
|
||||||
|
IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
|
||||||
|
if ( window != null ) {
|
||||||
|
DebugUIPlugin.errorDialog( window.getShell(), getErrorDialogTitle(), getErrorDialogMessage(), ms.getChildren()[0] ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DebugUIPlugin.log( ms );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected IAction getAction() {
|
||||||
|
return fAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAction( IAction action ) {
|
||||||
|
fAction = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IWorkbenchWindow getWindow() {
|
||||||
|
if ( getView() != null ) {
|
||||||
|
return getView().getViewSite().getWorkbenchWindow();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IStructuredSelection getSelection() {
|
||||||
|
return fSelection;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSelection( ISelection selection ) {
|
||||||
|
fSelection = (selection instanceof IStructuredSelection) ? (IStructuredSelection)selection : StructuredSelection.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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 abstract String getErrorDialogTitle();
|
||||||
|
|
||||||
|
protected abstract String getErrorDialogMessage();
|
||||||
|
|
||||||
|
protected abstract void doAction() throws DebugException;
|
||||||
|
|
||||||
|
protected abstract void update();
|
||||||
|
|
||||||
|
protected abstract void doHandleDebugEvent( DebugEvent event );
|
||||||
|
}
|
|
@ -2,7 +2,9 @@ LoadSymbolsActionDelegate.Unable_to_load_symbols_of_shared_library_1=Unable to l
|
||||||
LoadSymbolsActionDelegate.Operation_failed_1=Operation failed.
|
LoadSymbolsActionDelegate.Operation_failed_1=Operation failed.
|
||||||
LoadSymbolsForAllAction.Load_Symbols_For_All_1=Load Symbols For All
|
LoadSymbolsForAllAction.Load_Symbols_For_All_1=Load Symbols For All
|
||||||
LoadSymbolsForAllAction.Load_symbols_for_all_shared_libraries_1=Load symbols for all shared libraries.
|
LoadSymbolsForAllAction.Load_symbols_for_all_shared_libraries_1=Load symbols for all shared libraries.
|
||||||
|
LoadSymbolsForAllActionDelegate.Error(s)_occurred_loading_the_symbols_1=Error(s) occurred loading the symbols.
|
||||||
LoadSymbolsForAllAction.Load_Symbols_For_All_2=Load Symbols For All
|
LoadSymbolsForAllAction.Load_Symbols_For_All_2=Load Symbols For All
|
||||||
|
LoadSymbolsForAllActionDelegate.Error_1=Error
|
||||||
LoadSymbolsForAllAction.Unable_to_load_symbols_1=Unable to load symbols.
|
LoadSymbolsForAllAction.Unable_to_load_symbols_1=Unable to load symbols.
|
||||||
SignalPropertiesDialog.Title_1=Properties for signal ''{0}''
|
SignalPropertiesDialog.Title_1=Properties for signal ''{0}''
|
||||||
SignalPropertiesDialog.Description_label_1=Signal description: {0}.
|
SignalPropertiesDialog.Description_label_1=Signal description: {0}.
|
||||||
|
@ -37,3 +39,5 @@ ResumeAtLineActionDelegate.Missing_document=Missing document
|
||||||
ResumeAtLineActionDelegate.Empty_editor_1=Empty editor
|
ResumeAtLineActionDelegate.Empty_editor_1=Empty editor
|
||||||
ResumeAtLineActionDelegate.Operation_is_not_supported_1=Operation is not supported
|
ResumeAtLineActionDelegate.Operation_is_not_supported_1=Operation is not supported
|
||||||
AddGlobalsActionDelegate.Error(s)_occured_adding_globals_1=Error(s) occured adding globals.
|
AddGlobalsActionDelegate.Error(s)_occured_adding_globals_1=Error(s) occured adding globals.
|
||||||
|
AbstractRefreshActionDelegate.Error_1=Error
|
||||||
|
AbstractRefreshActionDelegate.Error(s)_occurred_refreshing_the_view_1=Error(s) occurred refreshing the view.
|
||||||
|
|
|
@ -1,81 +1,54 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Copyright (c) 2004 QNX Software Systems and others.
|
* Copyright (c) 2004 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* are made available under the terms of the Common Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* 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.model.ICDebugTarget;
|
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||||
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.debug.core.model.IDebugElement;
|
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.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.
|
* The delegate for the "Load Symbols For All" action of the Shared Libraries view.
|
||||||
*/
|
*/
|
||||||
public class LoadSymbolsForAllActionDelegate extends ActionDelegate implements IViewActionDelegate, IUpdate {
|
public class LoadSymbolsForAllActionDelegate extends AbstractViewActionDelegate {
|
||||||
|
|
||||||
private IAction fAction;
|
|
||||||
private IDebugView fView;
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#getErrorDialogTitle()
|
||||||
*/
|
*/
|
||||||
public void init( IViewPart view ) {
|
protected String getErrorDialogTitle() {
|
||||||
setView( view );
|
return ActionMessages.getString( "LoadSymbolsForAllActionDelegate.Error_1" ); //$NON-NLS-1$
|
||||||
if ( getView() != null ) {
|
}
|
||||||
getView().add( this );
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#getErrorDialogMessage()
|
||||||
|
*/
|
||||||
|
protected String getErrorDialogMessage() {
|
||||||
|
return ActionMessages.getString( "LoadSymbolsForAllActionDelegate.Error(s)_occurred_loading_the_symbols_1" ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doAction()
|
||||||
|
*/
|
||||||
|
protected void doAction() throws DebugException {
|
||||||
|
ICDebugTarget target = getDebugTarget( getView().getViewer().getInput() );
|
||||||
|
if ( target != null ) {
|
||||||
|
target.loadSymbols();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#update()
|
||||||
*/
|
*/
|
||||||
public void init( IAction action ) {
|
protected void update() {
|
||||||
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();
|
IAction action = getAction();
|
||||||
if ( getView() != null && action != null ) {
|
if ( getView() != null && action != null ) {
|
||||||
ICDebugTarget target = getDebugTarget( getView().getViewer().getInput() );
|
ICDebugTarget target = getDebugTarget( getView().getViewer().getInput() );
|
||||||
|
@ -83,22 +56,16 @@ public class LoadSymbolsForAllActionDelegate extends ActionDelegate implements I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doHandleDebugEvent(org.eclipse.debug.core.DebugEvent)
|
||||||
|
*/
|
||||||
|
protected void doHandleDebugEvent( DebugEvent event ) {
|
||||||
|
}
|
||||||
|
|
||||||
private ICDebugTarget getDebugTarget( Object element ) {
|
private ICDebugTarget getDebugTarget( Object element ) {
|
||||||
if ( element instanceof IDebugElement ) {
|
if ( element instanceof IDebugElement ) {
|
||||||
return (ICDebugTarget)((IDebugElement)element).getDebugTarget().getAdapter( ICDebugTarget.class );
|
return (ICDebugTarget)((IDebugElement)element).getDebugTarget().getAdapter( ICDebugTarget.class );
|
||||||
}
|
}
|
||||||
return null;
|
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() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.eclipse.cdt.debug.core.ICUpdateManager;
|
||||||
import org.eclipse.debug.core.model.IDebugElement;
|
import org.eclipse.debug.core.model.IDebugElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A delegate for the "Refresh" action of the Registers view.
|
* The delegate for the "Refresh" action of the Registers view.
|
||||||
*/
|
*/
|
||||||
public class RefreshRegistersAction extends AbstractRefreshActionDelegate {
|
public class RefreshRegistersAction extends AbstractRefreshActionDelegate {
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.eclipse.cdt.debug.core.ICUpdateManager;
|
||||||
import org.eclipse.debug.core.model.IDebugElement;
|
import org.eclipse.debug.core.model.IDebugElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A delegate for the "Refresh" action of the Shared Libraries view.
|
* The delegate for the "Refresh" action of the Shared Libraries view.
|
||||||
*/
|
*/
|
||||||
public class RefreshSharedLibrariesAction extends AbstractRefreshActionDelegate {
|
public class RefreshSharedLibrariesAction extends AbstractRefreshActionDelegate {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue