From ed8c15c83a843fbec0f27da1e9029e07e68a6922 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 17 Jan 2003 19:31:40 +0000 Subject: [PATCH] Implementation of the shared library view. --- debug/org.eclipse.cdt.debug.ui/ChangeLog | 10 ++ .../icons/full/clcl16/load_symbols_co.gif | Bin 0 -> 104 bytes .../full/cview16/sharedlibraries_view.gif | Bin 160 -> 153 bytes .../icons/full/dlcl16/load_symbols_co.gif | Bin 0 -> 81 bytes .../icons/full/elcl16/load_symbols_co.gif | Bin 0 -> 100 bytes .../full/eview16/sharedlibraries_view.gif | Bin 160 -> 153 bytes .../icons/full/obj16/library_obj.gif | Bin 0 -> 160 bytes .../icons/full/obj16/library_syms_obj.gif | Bin 0 -> 153 bytes .../icons/full/obj16/sharedlibraryl_obj.gif | Bin 160 -> 0 bytes .../icons/full/obj16/sharedlibraryu_obj.gif | Bin 168 -> 0 bytes .../plugin.properties | 2 + debug/org.eclipse.cdt.debug.ui/plugin.xml | 58 ++++++++ .../ui/CDTDebugModelPresentation.java | 34 +++++ .../cdt/debug/internal/ui/CDebugImages.java | 4 +- .../ui/actions/LoadSymbolsActionDelegate.java | 126 ++++++++++++++++++ .../ui/views/AbstractDebugEventHandler.java | 4 +- .../views/sharedlibs/SharedLibrariesView.java | 126 +++++++----------- .../SharedLibrariesViewEventHandler.java | 113 +++++++++++++++- 18 files changed, 393 insertions(+), 84 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/load_symbols_co.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/dlcl16/load_symbols_co.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/elcl16/load_symbols_co.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/library_obj.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/library_syms_obj.gif delete mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/sharedlibraryl_obj.gif delete mode 100644 debug/org.eclipse.cdt.debug.ui/icons/full/obj16/sharedlibraryu_obj.gif create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadSymbolsActionDelegate.java diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 42f1efcf973..b0caed64283 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,13 @@ +2003-01-17 Mikhail Khodjaiants + Implementation of the shared library view. + * LoadSymbolsActionDelegate.java + * SharedLibrariesView.java + * SharedLibrariesViewEventHandler.java + * CDTDebugModelPresentation.java + * CDebugImages.java + * plugin.properties + * plugin.xml + 2003-01-16 Mikhail Khodjaiants Implementing the Shared Libraries view. * SharedLibrariesView.java diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/load_symbols_co.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/clcl16/load_symbols_co.gif new file mode 100644 index 0000000000000000000000000000000000000000..4007422e4378d0055c796db221e8cfa70cce5bba GIT binary patch literal 104 zcmZ?wbhEHb6krfw_{6~Q9|Y|G-?#t&e|~+v{r&m&_3`!$3=E1tSr~y7gARxQsdZx3 z<=Ay6&z0wqluW}lR@V#C;#zaf6CMcrCcoYm5LL=(CH=$ejnVSM`vvoUaH%pdSOWmk C8YMdb literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/cview16/sharedlibraries_view.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/cview16/sharedlibraries_view.gif index d84096acfc9383166313a046840f0efe29c688f9..e45ab0f692c31807654c2c57d8302eb2ff866e87 100644 GIT binary patch literal 153 zcmV;K0A~M3Nk%w1VGsZi0J8u94-pFG=-u-4?eX*MRbDye=-Lku3V(<*e}x}_fB@p( zz2o4&+0>`*?AQPQ{{R30EC2ui01yBW000C|(8)<_O^IUb(qMp;2%zPa9T{GO!eBvz zPT0^Wg3!oFCJw-zaF<&p3XGwU!CW~E1f3G(6iJ6Onk>m|asYtC2V6CcIhREi?Etgi Hln4Mjf51XU literal 160 zcmZ?wbhEHb6krfw*v!C?xHQ}}Qh(B+?&(J+?6|)9*!@EvKfn3#>6MA4a_QheRx$Q#HSoJ zOXvF^RoYi$>iWs-;zxmij9`^5PkLNL5_X@}4Zp?IC~(5{d}8B*oVg5K&5XOxGO)aB I6Y0{|1j8rc8< literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/elcl16/load_symbols_co.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/elcl16/load_symbols_co.gif new file mode 100644 index 0000000000000000000000000000000000000000..2e4eca281c1a97341bc94570f0d37b21e13e0ece GIT binary patch literal 100 zcmZ?wbhEHb6krfw_{6~Q|NsB{_xCq6G|ZnrKR!O50R|L*vM_?!Iv@h1)`?k@W7i!& tWrl}RAzSn`Hs70n$g}&qOYn+yS}9>MoWdqrciyLMulD%A#-EA78UQ$zAvOR2 literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/eview16/sharedlibraries_view.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/eview16/sharedlibraries_view.gif index d84096acfc9383166313a046840f0efe29c688f9..e45ab0f692c31807654c2c57d8302eb2ff866e87 100644 GIT binary patch literal 153 zcmV;K0A~M3Nk%w1VGsZi0J8u94-pFG=-u-4?eX*MRbDye=-Lku3V(<*e}x}_fB@p( zz2o4&+0>`*?AQPQ{{R30EC2ui01yBW000C|(8)<_O^IUb(qMp;2%zPa9T{GO!eBvz zPT0^Wg3!oFCJw-zaF<&p3XGwU!CW~E1f3G(6iJ6Onk>m|asYtC2V6CcIhREi?Etgi Hln4Mjf51XU literal 160 zcmZ?wbhEHb6krfw*v!C?xHQ}}Qh(B+?&(J+?6|)9*!@EvKfn3#>6MA4a_QheRx$Q#HSoJ zOXvF^RoYi$>iWs-;zxmij9`^5PkLNL5_X@}4Zp?IC~(5{d}8B*oVg5K&5XOxGO)aB I6k@4Vd9WKw?iYqqrE#&o`Zt;^tLhkWK LK?V7EK?Z98DH}s3 literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/library_syms_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/library_syms_obj.gif new file mode 100644 index 0000000000000000000000000000000000000000..e45ab0f692c31807654c2c57d8302eb2ff866e87 GIT binary patch literal 153 zcmV;K0A~M3Nk%w1VGsZi0J8u94-pFG=-u-4?eX*MRbDye=-Lku3V(<*e}x}_fB@p( zz2o4&+0>`*?AQPQ{{R30EC2ui01yBW000C|(8)<_O^IUb(qMp;2%zPa9T{GO!eBvz zPT0^Wg3!oFCJw-zaF<&p3XGwU!CW~E1f3G(6iJ6Onk>m|asYtC2V6CcIhREi?Etgi Hln4Mjf51XU literal 0 HcmV?d00001 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/sharedlibraryl_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/full/obj16/sharedlibraryl_obj.gif deleted file mode 100644 index d84096acfc9383166313a046840f0efe29c688f9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 160 zcmZ?wbhEHb6krfw*v!C?xHQ}}Qh(B+?&(J+?6|)9*!@EvKfn3#>6MA4a_QheRx$Q#HSoJ zOXvF^RoYi$>iWs-;zxmij9`^5PkLNL5_X@}4Zp?IC~(5{d}8B*oVg5K&5XOxGO)aB Ii_#s& z(Z|nDdn@TTYw3Ldqe}Z~Ox-@2UHm8%kP)o1 + + + + + + + + + + + + + + + + @@ -748,6 +785,27 @@ + + + + + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java index 44996e8a508..07959ce0c69 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.ICDebugTargetType; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; +import org.eclipse.cdt.debug.core.model.ICSharedLibrary; import org.eclipse.cdt.debug.core.model.ICValue; import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.IDummyStackFrame; @@ -228,6 +229,10 @@ public class CDTDebugModelPresentation extends LabelProvider { return getVariableImage( (IVariable)element ); } + if ( element instanceof ICSharedLibrary ) + { + return getSharedLibraryImage( (ICSharedLibrary)element ); + } } catch( CoreException e ) { @@ -244,6 +249,12 @@ public class CDTDebugModelPresentation extends LabelProvider StringBuffer label = new StringBuffer(); try { + if ( element instanceof ICSharedLibrary ) + { + label.append( getSharedLibraryText( (ICSharedLibrary)element, showQualified ) ); + return label.toString(); + } + if ( element instanceof IRegisterGroup ) { label.append( ((IRegisterGroup)element).getName() ); @@ -478,6 +489,17 @@ public class CDTDebugModelPresentation extends LabelProvider return label; } + protected String getSharedLibraryText( ICSharedLibrary library, boolean qualified ) throws DebugException + { + String label = new String(); + IPath path = new Path( library.getFileName() ); + if ( !path.isEmpty() ) + label += ( qualified ? path.toOSString() : path.lastSegment() ); + return label + MessageFormat.format( " (Start address: ''{0}'' End address: ''{1}'')", + new String[] { CDebugUtils.toHexAddressString( library.getStartAddress() ), + CDebugUtils.toHexAddressString( library.getEndAddress() ) } ); + } + /** * Plug in the single argument to the resource String for the key to * get a formatted resource String. @@ -771,6 +793,18 @@ public class CDTDebugModelPresentation extends LabelProvider return fDebugImageRegistry.get( new CImageDescriptor( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ), 0 ) ); } + protected Image getSharedLibraryImage( ICSharedLibrary element ) throws DebugException + { + if ( element.areSymbolsLoaded() ) + { + return CDebugUIPlugin.getImageDescriptorRegistry().get( new CImageDescriptor( CDebugImages.DESC_OBJS_LOADED_SHARED_LIBRARY, 0 ) ); + } + else + { + return CDebugUIPlugin.getImageDescriptorRegistry().get( new CImageDescriptor( CDebugImages.DESC_OBJS_SHARED_LIBRARY, 0 ) ); + } + } + protected DisassemblyEditorInput getDisassemblyEditorInput( ICAddressBreakpoint breakpoint ) { IDebugTarget[] targets = DebugPlugin.getDefault().getLaunchManager().getDebugTargets(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index 73a3c73c3a6..a0161ed3a6c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -65,8 +65,8 @@ public class CDebugImages public static final String IMG_OBJS_DISASSEMBLY = NAME_PREFIX + "disassembly_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_PROJECT = NAME_PREFIX + "project_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_FOLDER = NAME_PREFIX + "folder_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_LOADED_SHARED_LIBRARY = NAME_PREFIX + "sharedlibraryl_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_SHARED_LIBRARY = NAME_PREFIX + "sharedlibraryu_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_LOADED_SHARED_LIBRARY = NAME_PREFIX + "library_syms_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_SHARED_LIBRARY = NAME_PREFIX + "library_obj.gif"; //$NON-NLS-1$ public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif"; //$NON-NLS-1$ public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif"; //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadSymbolsActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadSymbolsActionDelegate.java new file mode 100644 index 00000000000..8d2b056ff7a --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/LoadSymbolsActionDelegate.java @@ -0,0 +1,126 @@ +/* + *(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.ICSharedLibrary; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.MultiStatus; +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.swt.custom.BusyIndicator; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; + +/** + * Enter type comment. + * + * @since: Jan 17, 2003 + */ +public class LoadSymbolsActionDelegate implements IObjectActionDelegate +{ + private ICSharedLibrary fLibrary = null; + + /** + * Constructor for LoadSymbolsActionDelegate. + */ + public LoadSymbolsActionDelegate() + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart( IAction action, IWorkbenchPart targetPart ) + { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(IAction) + */ + public void run( IAction action ) + { + if ( getSharedLibrary() != null ) + { + final MultiStatus ms = new MultiStatus( CDebugUIPlugin.getUniqueIdentifier(), + DebugException.REQUEST_FAILED, "Unable to load symbols of shared library.", null ); + BusyIndicator.showWhile( Display.getCurrent(), + new Runnable() + { + public void run() + { + try + { + doAction( getSharedLibrary() ); + } + catch( DebugException e ) + { + ms.merge( e.getStatus() ); + } + } + } ); + if ( !ms.isOK() ) + { + IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow(); + if ( window != null ) + { + CDebugUIPlugin.errorDialog( "Operation failed.", ms ); + } + else + { + CDebugUIPlugin.log( ms ); + } + } + + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged( IAction action, ISelection selection ) + { + if ( selection instanceof IStructuredSelection ) + { + Object element = ((IStructuredSelection)selection).getFirstElement(); + if ( element instanceof ICSharedLibrary ) + { + boolean enabled = enablesFor( (ICSharedLibrary)element ); + action.setEnabled( enabled ); + if ( enabled ) + { + setSharedLibrary( (ICSharedLibrary)element ); + return; + } + } + } + action.setEnabled( false ); + setSharedLibrary( null ); + } + + protected void doAction( ICSharedLibrary library ) throws DebugException + { + library.loadSymbols(); + } + + private boolean enablesFor( ICSharedLibrary library ) + { + return ( library != null && !library.areSymbolsLoaded() ); + } + + private void setSharedLibrary( ICSharedLibrary library ) + { + fLibrary = library; + } + + protected ICSharedLibrary getSharedLibrary() + { + return fLibrary; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java index f3a2ac57a59..cedd98a8431 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/AbstractDebugEventHandler.java @@ -77,9 +77,7 @@ public abstract class AbstractDebugEventHandler implements IDebugEventSetListene { if ( isAvailable() ) { - final Object parent = - ( - (ITreeContentProvider)getTreeViewer().getContentProvider()).getParent( element ); + final Object parent = ((ITreeContentProvider)getTreeViewer().getContentProvider()).getParent( element ); // a parent can be null for a debug target or process that has not yet been associated // with a launch if ( parent != null ) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/sharedlibs/SharedLibrariesView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/sharedlibs/SharedLibrariesView.java index f13982e0dbf..12ae6dcfe1f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/sharedlibs/SharedLibrariesView.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/sharedlibs/SharedLibrariesView.java @@ -6,17 +6,13 @@ package org.eclipse.cdt.debug.internal.ui.views.sharedlibs; import org.eclipse.cdt.debug.core.ICSharedLibraryManager; -import org.eclipse.cdt.debug.core.model.ICSharedLibrary; -import org.eclipse.cdt.debug.internal.core.CDebugUtils; -import org.eclipse.cdt.debug.internal.ui.CDebugImages; -import org.eclipse.cdt.debug.internal.ui.CImageDescriptor; import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds; -import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler; -import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandlerView; import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IDebugElement; +import org.eclipse.debug.ui.AbstractDebugView; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; @@ -25,16 +21,10 @@ import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchPart; @@ -44,58 +34,50 @@ import org.eclipse.ui.IWorkbenchPart; * * @since: Jan 16, 2003 */ -public class SharedLibrariesView extends AbstractDebugEventHandlerView +public class SharedLibrariesView extends AbstractDebugView implements ISelectionListener, IPropertyChangeListener, IDebugExceptionHandler { /** - * Enter type comment. - * - * @since: Jan 16, 2003 + * Event handler for this view */ - public class SharedLibrariesViewLabelProvider extends LabelProvider - implements ITableLabelProvider - { - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(Object, int) - */ - public Image getColumnImage( Object element, int columnIndex ) - { - if ( columnIndex == 0 && element instanceof ICSharedLibrary ) - { - if ( ((ICSharedLibrary)element).areSymbolsLoaded() ) - { - return CDebugUIPlugin.getImageDescriptorRegistry().get( new CImageDescriptor( CDebugImages.DESC_OBJS_LOADED_SHARED_LIBRARY, 0 ) ); - } - else - { - return CDebugUIPlugin.getImageDescriptorRegistry().get( new CImageDescriptor( CDebugImages.DESC_OBJS_SHARED_LIBRARY, 0 ) ); - } - } - return null; - } + private SharedLibrariesViewEventHandler fEventHandler; - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(Object, int) - */ - public String getColumnText( Object element, int columnIndex ) + /** + * The model presentation used as the label provider for the tree viewer. + */ + private IDebugModelPresentation fModelPresentation; + + /** + * Sets the event handler for this view + * + * @param eventHandler event handler + */ + protected void setEventHandler( SharedLibrariesViewEventHandler eventHandler ) + { + fEventHandler = eventHandler; + } + + /** + * Returns the event handler for this view + * + * @return The event handler for this view + */ + protected SharedLibrariesViewEventHandler getEventHandler() + { + return fEventHandler; + } + + /** + * @see IWorkbenchPart#dispose() + */ + public void dispose() + { + super.dispose(); + if ( getEventHandler() != null ) { - if ( element instanceof ICSharedLibrary ) - { - switch( columnIndex ) - { - case 0: - return ((ICSharedLibrary)element).getFileName(); - case 1: - return CDebugUtils.toHexAddressString( ((ICSharedLibrary)element).getStartAddress() ); - case 2: - return CDebugUtils.toHexAddressString( ((ICSharedLibrary)element).getEndAddress() ); - case 3: - return ( ((ICSharedLibrary)element).areSymbolsLoaded() ) ? "Yes" : "No"; - } - } - return null; + getEventHandler().dispose(); } } @@ -105,25 +87,8 @@ public class SharedLibrariesView extends AbstractDebugEventHandlerView protected Viewer createViewer( Composite parent ) { TableViewer viewer = new TableViewer( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL ); - - Table table = viewer.getTable(); - table.setHeaderVisible( true ); - table.setLinesVisible( true ); - table.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - - // Create the table columns - new TableColumn( table, SWT.NULL ); - new TableColumn( table, SWT.NULL ); - new TableColumn( table, SWT.NULL ); - new TableColumn( table, SWT.NULL ); - TableColumn[] columns = table.getColumns(); - columns[0].setText( "Name" ); - columns[1].setText( "Start Address" ); - columns[2].setText( "End Address" ); - columns[3].setText( "Symbols" ); - viewer.setContentProvider( new SharedLibrariesViewContentProvider() ); - viewer.setLabelProvider( new SharedLibrariesViewLabelProvider() ); + viewer.setLabelProvider( getModelPresentation() ); // listen to selection in debug view getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); @@ -235,8 +200,17 @@ public class SharedLibrariesView extends AbstractDebugEventHandlerView * @param viewer the viewer associated with this view * @return an event handler */ - protected AbstractDebugEventHandler createEventHandler( Viewer viewer ) + protected SharedLibrariesViewEventHandler createEventHandler( Viewer viewer ) { return new SharedLibrariesViewEventHandler( this ); } + + protected IDebugModelPresentation getModelPresentation() + { + if ( fModelPresentation == null ) + { + fModelPresentation = DebugUITools.newDebugModelPresentation(); + } + return fModelPresentation; + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/sharedlibs/SharedLibrariesViewEventHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/sharedlibs/SharedLibrariesViewEventHandler.java index 91fdc2b03ce..6cc564dc6f7 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/sharedlibs/SharedLibrariesViewEventHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/sharedlibs/SharedLibrariesViewEventHandler.java @@ -6,24 +6,55 @@ package org.eclipse.cdt.debug.internal.ui.views.sharedlibs; import org.eclipse.cdt.debug.core.model.ICSharedLibrary; -import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler; import org.eclipse.debug.core.DebugEvent; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.IDebugEventSetListener; import org.eclipse.debug.ui.AbstractDebugView; +import org.eclipse.jface.viewers.TableViewer; /** * Enter type comment. * * @since: Jan 16, 2003 */ -public class SharedLibrariesViewEventHandler extends AbstractDebugEventHandler +public class SharedLibrariesViewEventHandler implements IDebugEventSetListener { + /** + * This event handler's view + */ + private AbstractDebugView fView; + /** * Constructor for SharedLibrariesViewEventHandler. * @param view */ public SharedLibrariesViewEventHandler( AbstractDebugView view ) { - super( view ); + setView( view ); + DebugPlugin.getDefault().addDebugEventListener( this ); + } + + /** + * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[]) + */ + public void handleDebugEvents( final DebugEvent[] events ) + { + if ( !isAvailable() ) + { + return; + } + Runnable r = new Runnable() + { + public void run() + { + if ( isAvailable() ) + { + doHandleDebugEvents( events ); + } + } + }; + + getView().asyncExec( r ); } /* (non-Javadoc) @@ -49,4 +80,80 @@ public class SharedLibrariesViewEventHandler extends AbstractDebugEventHandler } } } + + /** + * Refresh the given element in the viewer - must be called in UI thread. + */ + protected void refresh( Object element ) + { + if ( isAvailable() ) + { + getView().showViewer(); + getTableViewer().refresh( element ); + } + } + + /** + * Refresh the viewer - must be called in UI thread. + */ + public void refresh() + { + if ( isAvailable() ) + { + getView().showViewer(); + getTableViewer().refresh(); + } + } + + /** + * De-registers this event handler from the debug model. + */ + public void dispose() + { + DebugPlugin plugin = DebugPlugin.getDefault(); + plugin.removeDebugEventListener( this ); + } + + /** + * Returns the view this event handler is + * updating. + * + * @return debug view + */ + protected AbstractDebugView getView() + { + return fView; + } + + /** + * Sets the view this event handler is updating. + * + * @param view debug view + */ + private void setView( AbstractDebugView view ) + { + fView = view; + } + + /** + * Returns the viewer this event handler is updating. + * + * @return viewer + */ + protected TableViewer getTableViewer() + { + return (TableViewer)getView().getViewer(); + } + + /** + * Returns whether this event handler's viewer is + * currently available. + * + * @return whether this event handler's viewer is + * currently available + */ + protected boolean isAvailable() + { + return getView().isAvailable(); + } }