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

Implementing the Shared Libraries view.

This commit is contained in:
Mikhail Khodjaiants 2003-01-17 00:15:12 +00:00
parent a25c4af562
commit 2e36002edc
19 changed files with 749 additions and 4 deletions

View file

@ -1,3 +1,12 @@
2003-01-16 Mikhail Khodjaiants
Implementing the Shared Libraries view.
* ICSharedLibrary.java
* ICSharedLibraryManager.java
* CDebugElement.java
* CDebugTarget.java
* CSharedLibrary.java
* CSharedLibraryManager.java
2003-01-16 Mikhail Khodjaiants
* ICDILoadedEvent.java: Removed.

View file

@ -0,0 +1,28 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.core.runtime.IAdaptable;
/**
* Enter type comment.
*
* @since: Jan 15, 2003
*/
public interface ICSharedLibraryManager extends IAdaptable
{
void sharedLibraryLoaded( ICDISharedLibrary library );
void sharedLibraryUnloaded( ICDISharedLibrary library );
void symbolsLoaded( ICDISharedLibrary library );
ICSharedLibrary[] getSharedLibraries();
void dispose();
}

View file

@ -0,0 +1,54 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
/**
* Enter type comment.
*
* @since: Jan 15, 2003
*/
public interface ICSharedLibrary extends IDebugElement
{
/**
* Returns the name of shared library file.
*
* @return the name of shared library file
*/
String getFileName();
/**
* Returns the start address of this library.
*
* @return the start address of this library
*/
long getStartAddress();
/**
* Returns the end address of this library.
*
* @return the end address of this library
*/
long getEndAddress();
/**
* Returns whether the symbols of this library are read.
*
* @return whether the symbols of this library are read
*/
boolean areSymbolsLoaded();
/**
* Loads the library symbols.
*
* @throws DebugException if this method fails. Reasons include:
*/
void loadSymbols() throws DebugException;
void dispose();
}

View file

@ -0,0 +1,136 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.core;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.cdt.debug.core.ICSharedLibraryManager;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CSharedLibrary;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.model.IDebugTarget;
/**
* Enter type comment.
*
* @since: Jan 16, 2003
*/
public class CSharedLibraryManager implements ICSharedLibraryManager
{
private CDebugTarget fDebugTarget = null;
private ArrayList fSharedLibraries;
/**
* Constructor for CSharedLibraryManager.
*/
public CSharedLibraryManager( CDebugTarget target )
{
setDebugTarget( target );
fSharedLibraries = new ArrayList( 5 );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICSharedLibraryManager#sharedLibararyLoaded(ICDISharedLibrary)
*/
public synchronized void sharedLibraryLoaded( ICDISharedLibrary cdiLibrary )
{
CSharedLibrary library = new CSharedLibrary( fDebugTarget, cdiLibrary );
fSharedLibraries.add( library );
library.fireCreationEvent();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICSharedLibraryManager#sharedLibraryUnloaded(ICDISharedLibrary)
*/
public synchronized void sharedLibraryUnloaded( ICDISharedLibrary cdiLibrary )
{
CSharedLibrary library = find( cdiLibrary );
if ( library != null )
{
fSharedLibraries.remove( library );
library.dispose();
library.fireTerminateEvent();
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICSharedLibraryManager#symbolsLoaded(ICDISharedLibrary)
*/
public void symbolsLoaded( ICDISharedLibrary cdiLibrary )
{
CSharedLibrary library = find( cdiLibrary );
if ( library != null )
{
library.fireChangeEvent( DebugEvent.STATE );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICSharedLibraryManager#getSharedLibraries()
*/
public ICSharedLibrary[] getSharedLibraries()
{
return (ICSharedLibrary[])fSharedLibraries.toArray( new ICSharedLibrary[fSharedLibraries.size()] );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICSharedLibraryManager#dispose()
*/
public void dispose()
{
Iterator it = fSharedLibraries.iterator();
while( it.hasNext() )
{
((ICSharedLibrary)it.next()).dispose();
}
fSharedLibraries.clear();
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
*/
public Object getAdapter( Class adapter )
{
if ( adapter.equals( ICSharedLibraryManager.class ) )
{
return this;
}
if ( adapter.equals( CSharedLibraryManager.class ) )
{
return this;
}
if ( adapter.equals( IDebugTarget.class ) )
{
return fDebugTarget;
}
return null;
}
public IDebugTarget getDebugTarget()
{
return fDebugTarget;
}
protected void setDebugTarget( CDebugTarget target )
{
fDebugTarget = target;
}
protected CSharedLibrary find( ICDISharedLibrary cdiLibrary )
{
Iterator it = fSharedLibraries.iterator();
while( it.hasNext() )
{
CSharedLibrary library = (CSharedLibrary)it.next();
if ( library.getCDISharedLibrary().equals( cdiLibrary ) )
return library;
}
return null;
}
}

View file

@ -123,7 +123,7 @@ public class CDebugElement extends PlatformObject
/**
* Fires a debug event marking the creation of this element.
*/
protected void fireCreationEvent()
public void fireCreationEvent()
{
fireEvent( new DebugEvent( this, DebugEvent.CREATE ) );
}

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.ICBreakpointManager;
import org.eclipse.cdt.debug.core.ICMemoryManager;
import org.eclipse.cdt.debug.core.ICSharedLibraryManager;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager;
@ -48,6 +49,7 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
@ -69,6 +71,7 @@ import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
import org.eclipse.cdt.debug.internal.core.CMemoryManager;
import org.eclipse.cdt.debug.internal.core.CSharedLibraryManager;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager;
@ -218,6 +221,11 @@ public class CDebugTarget extends CDebugElement
*/
private DisassemblyManager fDisassemblyManager;
/**
* A shared library manager for this target.
*/
private CSharedLibraryManager fSharedLibraryManager;
/**
* Whether the debugger process is default.
*/
@ -256,6 +264,7 @@ public class CDebugTarget extends CDebugElement
fSupportsDisconnect = allowsDisconnect & getConfiguration().supportsDisconnect();
setThreadList( new ArrayList( 5 ) );
setDisassemblyManager( new DisassemblyManager( this ) );
setSharedLibraryManager( new CSharedLibraryManager( this ) );
initialize();
DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this );
DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this );
@ -867,6 +876,8 @@ public class CDebugTarget extends CDebugElement
return this;
if ( adapter.equals( DisassemblyManager.class ) )
return fDisassemblyManager;
if ( adapter.equals( ICSharedLibraryManager.class ) )
return fSharedLibraryManager;
return super.getAdapter( adapter );
}
@ -888,6 +899,10 @@ public class CDebugTarget extends CDebugElement
{
handleThreadCreatedEvent( (ICDICreatedEvent)event );
}
if ( source instanceof ICDISharedLibrary )
{
getSharedLibraryManager().sharedLibraryLoaded( (ICDISharedLibrary)source );
}
}
else if ( event instanceof ICDISuspendedEvent )
{
@ -916,6 +931,10 @@ public class CDebugTarget extends CDebugElement
{
handleThreadTerminatedEvent( (ICDIDestroyedEvent)event );
}
if ( source instanceof ICDISharedLibrary )
{
getSharedLibraryManager().sharedLibraryUnloaded( (ICDISharedLibrary)source );
}
}
else if ( event instanceof ICDIDisconnectedEvent )
{
@ -930,6 +949,10 @@ public class CDebugTarget extends CDebugElement
{
handleChangedEvent( (ICDIChangedEvent)event );
}
if ( source instanceof ICDISharedLibrary )
{
getSharedLibraryManager().symbolsLoaded( (ICDISharedLibrary)source );
}
}
else if ( event instanceof ICDIRestartedEvent )
{
@ -1083,6 +1106,7 @@ public class CDebugTarget extends CDebugElement
DebugPlugin.getDefault().getExpressionManager().removeExpressionListener( this );
DebugPlugin.getDefault().getLaunchManager().removeLaunchListener( this );
disposeMemoryManager();
disposeSharedLibraryManager();
removeAllExpressions();
try
{
@ -2076,6 +2100,21 @@ public class CDebugTarget extends CDebugElement
return fDisassemblyManager;
}
protected void setSharedLibraryManager( CSharedLibraryManager libman )
{
fSharedLibraryManager = libman;
}
protected CSharedLibraryManager getSharedLibraryManager()
{
return fSharedLibraryManager;
}
protected void disposeSharedLibraryManager()
{
fSharedLibraryManager.dispose();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICBreakpointManager#getBreakpointAddress(IBreakpoint)
*/

View file

@ -0,0 +1,112 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.debug.core.DebugException;
/**
* Enter type comment.
*
* @since: Jan 16, 2003
*/
public class CSharedLibrary extends CDebugElement
implements ICSharedLibrary,
ICDIEventListener
{
private ICDISharedLibrary fCDILib = null;
/**
* Constructor for CSharedLibrary.
* @param target
*/
public CSharedLibrary( CDebugTarget target, ICDISharedLibrary cdiLib )
{
super( target );
fCDILib = cdiLib;
getCDISession().getEventManager().addEventListener( this );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICSharedLibrary#getFileName()
*/
public String getFileName()
{
if ( getCDISharedLibrary() != null )
return getCDISharedLibrary().getFileName();
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICSharedLibrary#getStartAddress()
*/
public long getStartAddress()
{
if ( getCDISharedLibrary() != null )
return getCDISharedLibrary().getStartAddress();
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICSharedLibrary#getEndAddress()
*/
public long getEndAddress()
{
if ( getCDISharedLibrary() != null )
return getCDISharedLibrary().getEndAddress();
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICSharedLibrary#areSymbolsLoaded()
*/
public boolean areSymbolsLoaded()
{
if ( getCDISharedLibrary() != null )
return getCDISharedLibrary().areSymbolsLoaded();
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICSharedLibrary#loadSymbols()
*/
public void loadSymbols() throws DebugException
{
try
{
if ( getCDISharedLibrary() != null )
getCDISharedLibrary().loadSymbols();
}
catch( CDIException e )
{
targetRequestFailed( e.getMessage(), null );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICSharedLibrary#dispose()
*/
public void dispose()
{
getCDISession().getEventManager().removeEventListener( this );
}
public ICDISharedLibrary getCDISharedLibrary()
{
return fCDILib;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener#handleDebugEvent(ICDIEvent)
*/
public void handleDebugEvent( ICDIEvent event )
{
}
}

View file

@ -1,3 +1,17 @@
2003-01-16 Mikhail Khodjaiants
Implementing the Shared Libraries view.
* SharedLibrariesView.java
* SharedLibrariesViewContentProvider.java
* SharedLibrariesViewEventHandler.java
* CDebugImages.java
* ICDebugHelpContextIds.java
* plugin.properties
* plugin.xml
* icons/full/cview16/sharedlibraries_view.gif
* icons/full/eview16/sharedlibraries_view.gif
* icons/full/obj16/sharedlibraryl_obj.gif
* icons/full/obj16/sharedlibraryu_obj.gif
2003-01-15 Mikhail Khodjaiants
The 'getDefaultEditor' method returns 'null' for file names that don't have an extension and
are not registered with some editor. Use the default text editor in this case.

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

View file

@ -8,6 +8,7 @@ providerName=Eclipse.org
RegistersView.name=Registers
MemoryView.name=Memory
SharedLibrariesView.name=Shared Libraries
CDebuggerPage.name=C Debugger UI Page
MemoryPreferencePage.name=Memory View

View file

@ -48,6 +48,13 @@
class="org.eclipse.cdt.debug.internal.ui.views.memory.MemoryView"
id="org.eclipse.cdt.debug.ui.MemoryView">
</view>
<view
name="%SharedLibrariesView.name"
icon="icons/full/cview16/sharedlibraries_view.gif"
category="org.eclipse.debug.ui"
class="org.eclipse.cdt.debug.internal.ui.views.sharedlibs.SharedLibrariesView"
id="org.eclipse.cdt.debug.ui.SharedLibrariesView">
</view>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
@ -58,14 +65,16 @@
relationship="stack"
id="org.eclipse.cdt.debug.ui.RegistersView">
</view>
</perspectiveExtension>
<perspectiveExtension
targetID="org.eclipse.debug.ui.DebugPerspective">
<view
relative="org.eclipse.debug.ui.VariableView"
relationship="stack"
id="org.eclipse.cdt.debug.ui.MemoryView">
</view>
<view
relative="org.eclipse.debug.ui.VariableView"
relationship="stack"
id="org.eclipse.cdt.debug.ui.SharedLibrariesView">
</view>
</perspectiveExtension>
</extension>
<extension

View file

@ -65,6 +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_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$
@ -112,6 +114,8 @@ public class CDebugImages
public static final ImageDescriptor DESC_OBJS_DISASSEMBLY = createManaged( T_OBJ, IMG_OBJS_DISASSEMBLY );
public static final ImageDescriptor DESC_OBJS_PROJECT = createManaged( T_OBJ, IMG_OBJS_PROJECT );
public static final ImageDescriptor DESC_OBJS_FOLDER = createManaged( T_OBJ, IMG_OBJS_FOLDER );
public static final ImageDescriptor DESC_OBJS_LOADED_SHARED_LIBRARY = createManaged( T_OBJ, IMG_OBJS_LOADED_SHARED_LIBRARY );
public static final ImageDescriptor DESC_OBJS_SHARED_LIBRARY = createManaged( T_OBJ, IMG_OBJS_SHARED_LIBRARY );
public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_SOURCE_LOCATION ); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_ADD_PRJ_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_PRJ_SOURCE_LOCATION ); //$NON-NLS-1$
public static final ImageDescriptor DESC_WIZBAN_ADD_DIR_SOURCE_LOCATION = createManaged( T_WIZBAN, IMG_WIZBAN_ADD_DIR_SOURCE_LOCATION ); //$NON-NLS-1$

View file

@ -34,6 +34,7 @@ public interface ICDebugHelpContextIds
// Views
public static final String REGISTERS_VIEW = PREFIX + "registers_view_context"; //$NON-NLS-1$
public static final String MEMORY_VIEW = PREFIX + "memory_view_context"; //$NON-NLS-1$
public static final String SHARED_LIBRARIES_VIEW = PREFIX + "shared_libraries_view_context"; //$NON-NLS-1$
// Preference pages
public static final String MEMORY_PREFERENCE_PAGE = PREFIX + "memory_preference_page_context"; //$NON-NLS-1$

View file

@ -0,0 +1,242 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
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.IDebugUIConstants;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
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;
/**
* Enter type comment.
*
* @since: Jan 16, 2003
*/
public class SharedLibrariesView extends AbstractDebugEventHandlerView
implements ISelectionListener,
IPropertyChangeListener,
IDebugExceptionHandler
{
/**
* Enter type comment.
*
* @since: Jan 16, 2003
*/
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;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(Object, int)
*/
public String getColumnText( Object element, int columnIndex )
{
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;
}
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite)
*/
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() );
// listen to selection in debug view
getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
setEventHandler( createEventHandler( viewer ) );
return viewer;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractDebugView#createActions()
*/
protected void createActions()
{
// set initial content here, as viewer has to be set
setInitialContent();
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractDebugView#getHelpContextId()
*/
protected String getHelpContextId()
{
return ICDebugHelpContextIds.SHARED_LIBRARIES_VIEW;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractDebugView#fillContextMenu(IMenuManager)
*/
protected void fillContextMenu( IMenuManager menu )
{
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractDebugView#configureToolBar(IToolBarManager)
*/
protected void configureToolBar( IToolBarManager tbm )
{
tbm.add( new Separator( this.getClass().getName() ) );
}
/* (non-Javadoc)
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
*/
public void selectionChanged( IWorkbenchPart part, ISelection selection )
{
if ( selection instanceof IStructuredSelection )
{
setViewerInput( (IStructuredSelection)selection );
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(PropertyChangeEvent)
*/
public void propertyChange( PropertyChangeEvent event )
{
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler#handleException(DebugException)
*/
public void handleException( DebugException e )
{
}
protected void setViewerInput( IStructuredSelection ssel )
{
ICSharedLibraryManager slm = null;
if ( ssel != null && ssel.size() == 1 )
{
Object input = ssel.getFirstElement();
if ( input instanceof IDebugElement )
{
slm = (ICSharedLibraryManager)((IDebugElement)input).getDebugTarget().getAdapter( ICSharedLibraryManager.class );
}
}
Object current = getViewer().getInput();
if ( current != null && current.equals( slm ) )
{
return;
}
showViewer();
getViewer().setInput( slm );
updateObjects();
}
/**
* Initializes the viewer input on creation
*/
protected void setInitialContent()
{
ISelection selection =
getSite().getPage().getSelection( IDebugUIConstants.ID_DEBUG_VIEW );
if ( selection instanceof IStructuredSelection && !selection.isEmpty() )
{
setViewerInput( (IStructuredSelection)selection );
}
else
{
setViewerInput( null );
}
}
/**
* Creates this view's event handler.
*
* @param viewer the viewer associated with this view
* @return an event handler
*/
protected AbstractDebugEventHandler createEventHandler( Viewer viewer )
{
return new SharedLibrariesViewEventHandler( this );
}
}

View file

@ -0,0 +1,44 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui.views.sharedlibs;
import org.eclipse.cdt.debug.core.ICSharedLibraryManager;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
/**
* Enter type comment.
*
* @since: Jan 16, 2003
*/
public class SharedLibrariesViewContentProvider implements IStructuredContentProvider
{
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object)
*/
public Object[] getElements( Object parent )
{
if ( parent != null && parent instanceof ICSharedLibraryManager )
{
return ((ICSharedLibraryManager)parent).getSharedLibraries();
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose()
{
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object)
*/
public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
{
}
}

View file

@ -0,0 +1,52 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
*/
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.ui.AbstractDebugView;
/**
* Enter type comment.
*
* @since: Jan 16, 2003
*/
public class SharedLibrariesViewEventHandler extends AbstractDebugEventHandler
{
/**
* Constructor for SharedLibrariesViewEventHandler.
* @param view
*/
public SharedLibrariesViewEventHandler( AbstractDebugView view )
{
super( view );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler#doHandleDebugEvents(DebugEvent[])
*/
protected void doHandleDebugEvents( DebugEvent[] events )
{
for( int i = 0; i < events.length; i++ )
{
DebugEvent event = events[i];
if ( event.getSource() instanceof ICSharedLibrary )
{
switch( event.getKind() )
{
case DebugEvent.CREATE:
case DebugEvent.TERMINATE:
refresh();
break;
case DebugEvent.CHANGE :
refresh( event.getSource() );
break;
}
}
}
}
}