From e5e1f62891ed1c7ac903ec75c655c97490a95a4e Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Mon, 14 Jun 2004 01:41:44 +0000 Subject: [PATCH] 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. --- debug/org.eclipse.cdt.debug.ui/ChangeLog | 13 ++ .../AbstractAutoRefreshActionDelegate.java | 48 ++++- .../AbstractRefreshActionDelegate.java | 180 +++-------------- .../actions/AbstractViewActionDelegate.java | 187 ++++++++++++++++++ .../ui/actions/ActionMessages.properties | 4 + .../LoadSymbolsForAllActionDelegate.java | 103 ++++------ .../ui/actions/RefreshRegistersAction.java | 2 +- .../actions/RefreshSharedLibrariesAction.java | 2 +- 8 files changed, 310 insertions(+), 229 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractViewActionDelegate.java diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index cbe21bd2cf2..ad2ed30f4e7 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -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 New implementation of the "Load Symbols For All" action of the Shared Libraries view. Fixes for the "Auto-Refresh" and "refresh" actions. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractAutoRefreshActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractAutoRefreshActionDelegate.java index fe71ad8dfce..dc6ae6d9a94 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractAutoRefreshActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractAutoRefreshActionDelegate.java @@ -10,15 +10,19 @@ ***********************************************************************/ 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.debug.core.DebugException; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbenchPart; /** * The superclass for all "Auto-Refresh" action delegates. */ -public abstract class AbstractAutoRefreshActionDelegate extends AbstractRefreshActionDelegate { +public abstract class AbstractAutoRefreshActionDelegate extends AbstractRefreshActionDelegate implements Observer{ /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractRefreshActionDelegate#doAction() @@ -55,4 +59,46 @@ public abstract class AbstractAutoRefreshActionDelegate extends AbstractRefreshA 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(); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractRefreshActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractRefreshActionDelegate.java index 6ed74d18447..fa0713cb2e9 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractRefreshActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractRefreshActionDelegate.java @@ -1,134 +1,43 @@ /********************************************************************** * 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 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: + * + * Contributors: * QNX Software Systems - Initial API and implementation - ***********************************************************************/ +***********************************************************************/ 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; /** * 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; - - private IDebugView fView; - - private IStructuredSelection fSelection; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#getErrorDialogTitle() */ - 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 ); - } + protected String getErrorDialogTitle() { + return ActionMessages.getString( "AbstractRefreshActionDelegate.Error_1" ); //$NON-NLS-1$ } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction) + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#getErrorDialogMessage() */ - public void init( IAction action ) { - setAction( action ); - action.setEnabled( false ); - super.init( action ); + protected String getErrorDialogMessage() { + return ActionMessages.getString( "AbstractRefreshActionDelegate.Error(s)_occurred_refreshing_the_view_1" ); //$NON-NLS-1$ } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.actions.ActionDelegate#dispose() + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doAction() */ - 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 { if ( getView() != null ) { ICUpdateManager um = getUpdateManager( getView().getViewer().getInput() ); @@ -137,23 +46,9 @@ public abstract class AbstractRefreshActionDelegate extends ActionDelegate imple } } - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#update() */ - 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 ) { @@ -168,42 +63,9 @@ public abstract class AbstractRefreshActionDelegate extends ActionDelegate imple } } - 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[]) + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doHandleDebugEvent(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: @@ -219,4 +81,6 @@ public abstract class AbstractRefreshActionDelegate extends ActionDelegate imple break; } } -} \ No newline at end of file + + protected abstract ICUpdateManager getUpdateManager( Object element ); +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractViewActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractViewActionDelegate.java new file mode 100644 index 00000000000..3131af3b7f5 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AbstractViewActionDelegate.java @@ -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 ); +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties index 5075fddc126..3d845c12f7c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties @@ -2,7 +2,9 @@ LoadSymbolsActionDelegate.Unable_to_load_symbols_of_shared_library_1=Unable to l LoadSymbolsActionDelegate.Operation_failed_1=Operation failed. LoadSymbolsForAllAction.Load_Symbols_For_All_1=Load Symbols For All 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 +LoadSymbolsForAllActionDelegate.Error_1=Error LoadSymbolsForAllAction.Unable_to_load_symbols_1=Unable to load symbols. SignalPropertiesDialog.Title_1=Properties for signal ''{0}'' SignalPropertiesDialog.Description_label_1=Signal description: {0}. @@ -37,3 +39,5 @@ ResumeAtLineActionDelegate.Missing_document=Missing document ResumeAtLineActionDelegate.Empty_editor_1=Empty editor ResumeAtLineActionDelegate.Operation_is_not_supported_1=Operation is not supported 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. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadSymbolsForAllActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadSymbolsForAllActionDelegate.java index 5797e1d2047..84ceedb9ef4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadSymbolsForAllActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadSymbolsForAllActionDelegate.java @@ -1,81 +1,54 @@ /********************************************************************** * 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 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: + * + * 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.model.ICDebugTarget; +import org.eclipse.debug.core.DebugEvent; 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. + * The 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; +public class LoadSymbolsForAllActionDelegate extends AbstractViewActionDelegate { /* (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 ) { - setView( view ); - if ( getView() != null ) { - getView().add( this ); + protected String getErrorDialogTitle() { + return ActionMessages.getString( "LoadSymbolsForAllActionDelegate.Error_1" ); //$NON-NLS-1$ + } + + /* (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) - * @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 ) { - 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() { + protected void update() { IAction action = getAction(); if ( getView() != null && action != null ) { 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 ) { 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() ); - } - } - } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RefreshRegistersAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RefreshRegistersAction.java index 2f0f5610008..1dc0bf9fb09 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RefreshRegistersAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RefreshRegistersAction.java @@ -15,7 +15,7 @@ import org.eclipse.cdt.debug.core.ICUpdateManager; 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 { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RefreshSharedLibrariesAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RefreshSharedLibrariesAction.java index 1efdff14f53..ea4dbeb3bab 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RefreshSharedLibrariesAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RefreshSharedLibrariesAction.java @@ -15,7 +15,7 @@ import org.eclipse.cdt.debug.core.ICUpdateManager; 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 {