diff --git a/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog b/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog index d4776c1498c..16b9d4b38fb 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog @@ -1,3 +1,15 @@ +2003-02-11 Mikhail Khodjaiants + The 'Automatically Load Symbols' action is added to the 'Shared Libraries' view. + * SetAutoSolibActionDelegate.java: new + * plugin.properties + * plugin.xml + * icons/full/clcl16/auto_solib_co.gif: new + * icons/full/dlcl16/auto_solib_co.gif: new + * icons/full/elcl16/auto_solib_co.gif: new + +2003-02-11 Mikhail Khodjaiants + New package 'org.eclipse.cdt.debug.mi.internal.ui.actions' is added. + 2003-02-06 Alain Magloire * src/.../internal/ui/CygwinDebuggerPage.java (updateLaunchConfigurationDialog): diff --git a/debug/org.eclipse.cdt.debug.mi.ui/icons/full/clcl16/auto_solib_co.gif b/debug/org.eclipse.cdt.debug.mi.ui/icons/full/clcl16/auto_solib_co.gif new file mode 100644 index 00000000000..5a3fe16f204 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.mi.ui/icons/full/clcl16/auto_solib_co.gif differ diff --git a/debug/org.eclipse.cdt.debug.mi.ui/icons/full/dlcl16/auto_solib_co.gif b/debug/org.eclipse.cdt.debug.mi.ui/icons/full/dlcl16/auto_solib_co.gif new file mode 100644 index 00000000000..e8771f1e7e3 Binary files /dev/null and b/debug/org.eclipse.cdt.debug.mi.ui/icons/full/dlcl16/auto_solib_co.gif differ diff --git a/debug/org.eclipse.cdt.debug.mi.ui/icons/full/elcl16/auto_solib_co.gif b/debug/org.eclipse.cdt.debug.mi.ui/icons/full/elcl16/auto_solib_co.gif new file mode 100644 index 00000000000..e6a4a9728ee Binary files /dev/null and b/debug/org.eclipse.cdt.debug.mi.ui/icons/full/elcl16/auto_solib_co.gif differ diff --git a/debug/org.eclipse.cdt.debug.mi.ui/plugin.properties b/debug/org.eclipse.cdt.debug.mi.ui/plugin.properties index efdba4504df..7d444eef8ba 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.mi.ui/plugin.properties @@ -2,3 +2,6 @@ pluginName=C/C++ Development Tools GDB/MI CDI Debugger UI providerName=Eclipse.org MIPreferencePage.name=GDB MI + +SetAutoSolibAction.label=Automatically Load Shared Libraries +SetAutoSolibAction.tooltip=Automatically Load Shared Libraries On/Off diff --git a/debug/org.eclipse.cdt.debug.mi.ui/plugin.xml b/debug/org.eclipse.cdt.debug.mi.ui/plugin.xml index 533af6f1770..95e125b925e 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.mi.ui/plugin.xml @@ -46,5 +46,31 @@ id="org.eclipse.cdt.debug.mi.ui.MIPreferencePage"> + + + + + + + + + + diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/SetAutoSolibActionDelegate.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/SetAutoSolibActionDelegate.java new file mode 100644 index 00000000000..38f2b5bcf95 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/SetAutoSolibActionDelegate.java @@ -0,0 +1,287 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.mi.internal.ui.actions; + +import org.eclipse.cdt.debug.core.ICSharedLibraryManager; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IDebugElement; +import org.eclipse.debug.ui.IDebugUIConstants; +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.ui.IPartListener; +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; + +/** + * Enter type comment. + * + * @since: Feb 11, 2003 + */ +public class SetAutoSolibActionDelegate implements IViewActionDelegate, + ISelectionListener, + IPartListener +{ + private IViewPart fView = null; + private IAction fAction; + private IStructuredSelection fSelection; + private IStatus fStatus = null; + + /** + * Constructor for SetAutoSolibActionDelegate. + */ + public SetAutoSolibActionDelegate() + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart) + */ + public void init( IViewPart view ) + { + fView = view; + view.getSite().getPage().addPartListener( this ); + view.getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection) + */ + public void selectionChanged( IWorkbenchPart part, ISelection selection ) + { + if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) + { + if ( selection instanceof IStructuredSelection ) + { + setSelection( (IStructuredSelection)selection ); + } + else + { + setSelection( null ); + } + update( getAction() ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(IAction) + */ + public void run( IAction action ) + { + final IStructuredSelection selection = getSelection(); + if ( selection != null && selection.size() != 1 ) + return; + BusyIndicator.showWhile( Display.getCurrent(), + new Runnable() + { + public void run() + { + try + { + doAction( selection.getFirstElement() ); + setStatus( null ); + } + catch( DebugException e ) + { + setStatus( e.getStatus() ); + } + } + } ); + if ( getStatus() != null && !getStatus().isOK() ) + { + IWorkbenchWindow window= CDebugUIPlugin.getActiveWorkbenchWindow(); + if ( window != null ) + { + CDebugUIPlugin.errorDialog( getErrorDialogMessage(), getStatus() ); + } + else + { + CDebugUIPlugin.log( getStatus() ); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged( IAction action, ISelection selection ) + { + setAction( action ); + if ( getView() != null ) + { + update( action ); + } + } + + protected void update( IAction action ) + { + if ( action != null ) + { + action.setEnabled( getEnableStateForSelection( getSelection() ) ); + action.setChecked( getCheckStateForSelection( getSelection() ) ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart) + */ + public void partActivated( IWorkbenchPart part ) + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart) + */ + public void partBroughtToTop( IWorkbenchPart part ) + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart) + */ + public void partClosed( IWorkbenchPart part ) + { + if ( part.equals( getView() ) ) + { + dispose(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart) + */ + public void partDeactivated( IWorkbenchPart part ) + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart) + */ + public void partOpened( IWorkbenchPart part ) + { + } + + protected IViewPart getView() + { + return fView; + } + + protected void setView( IViewPart viewPart ) + { + fView = viewPart; + } + + protected void setAction( IAction action ) + { + fAction = action; + } + + protected IAction getAction() + { + return fAction; + } + + private void setSelection( IStructuredSelection selection ) + { + fSelection = selection; + } + + private IStructuredSelection getSelection() + { + return fSelection; + } + + protected void dispose() + { + if ( getView() != null ) + { + getView().getViewSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + getView().getViewSite().getPage().removePartListener( this ); + } + } + + protected boolean getCheckStateForSelection( IStructuredSelection selection ) + { + if ( selection == null || selection.size() != 1 ) + { + return false; + } + Object element = selection.getFirstElement(); + if ( element instanceof IDebugElement ) + { + ICSharedLibraryManager slm = (ICSharedLibraryManager)((IDebugElement)element).getDebugTarget().getAdapter( ICSharedLibraryManager.class ); + if ( slm != null ) + { + return slm.getAutoLoadSymbols(); + } + } + return false; + } + + protected boolean getEnableStateForSelection( IStructuredSelection selection ) + { + if ( selection == null || selection.size() != 1 ) + { + return false; + } + Object element = selection.getFirstElement(); + return ( element instanceof IDebugElement && + ((IDebugElement)element).getDebugTarget().isSuspended() && + ((IDebugElement)element).getDebugTarget().getAdapter( ICSharedLibraryManager.class ) != null ); + } + + protected String getStatusMessage() + { + return "Exceptions occurred attempting to set 'Automaticaly Load Symbols' mode."; + } + + /** + * @see AbstractDebugActionDelegate#getErrorDialogMessage() + */ + protected String getErrorDialogMessage() + { + return "Set 'Automatically Load Symbols' mode failed."; + } + + protected void setStatus( IStatus status ) + { + fStatus = status; + } + + protected IStatus getStatus() + { + return fStatus; + } + + protected void doAction( Object element ) throws DebugException + { + if ( getView() == null ) + return; + if ( element instanceof IDebugElement ) + { + ICSharedLibraryManager slm = (ICSharedLibraryManager)((IDebugElement)element).getDebugTarget().getAdapter( ICSharedLibraryManager.class ); + if ( slm != null && getAction() != null ) + { + try + { + slm.setAutoLoadSymbols( getAction().isChecked() ); + } + catch( DebugException e ) + { + getAction().setChecked( slm.getAutoLoadSymbols() ); + throw e; + } + } + } + } +}