1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 82264: Enhance the Shared Libraries view. Removed the Shared Libraries view.

This commit is contained in:
Mikhail Khodjaiants 2005-02-18 19:58:14 +00:00
parent fac0ffa530
commit c67d109f69
12 changed files with 17 additions and 863 deletions

View file

@ -1,3 +1,18 @@
2005-02-17 Mikhail Khodjaiants
Bug 82264: Enhance the Shared Libraries view.
Removed the Shared Libraries view.
* CDebugModelPresentation.java
* LoadSymbolsActionDelegate.java
* LoadSymbolsForAllActionDelegate.java
* SharedLibrariesMessages.java
* SharedLibrariesMessages.properties
* SharedLibrariesView.java
* SharedLibrariesViewContentProvider.java
* SharedLibrariesViewEventHandler.java
* ICDebugUIConstants.java
* plugin.properties
* plugin.xml
2005-02-17 Mikhail Khodjaiants
Bug 82264: Enhance the Shared Libraries view.
No need to compute the module's labels in background.

View file

@ -13,14 +13,12 @@ pluginName=C/C++ Development Tools Debugger UI
providerName=Eclipse.org
MemoryView.name=Memory
SharedLibrariesView.name=Shared Libraries
ModulesView.name=Modules
SignalsView.name=Signals
CDebuggerPage.name=C Debugger UI Page
MemoryPreferencePage.name=Memory View
CDebugPreferencePage.name=Debug
SharedLibrariesPreferencePage.name=Shared Libraries View
SourcePreferencePage.name=Source Code Locations
RunMenu.label=&Run

View file

@ -40,13 +40,6 @@
</extension>
<extension
point="org.eclipse.ui.views">
<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>
<view
name="%SignalsView.name"
icon="icons/full/cview16/signals_view.gif"
@ -72,15 +65,6 @@
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.debug.ui.DebugPerspective">
<view
relative="org.eclipse.debug.ui.VariableView"
visible="false"
relationship="stack"
id="org.eclipse.cdt.debug.ui.SharedLibrariesView">
</view>
<viewShortcut
id="org.eclipse.cdt.debug.ui.SharedLibrariesView">
</viewShortcut>
<view
relative="org.eclipse.debug.ui.VariableView"
visible="false"
@ -429,45 +413,6 @@
id="org.eclipse.cdt.debug.internal.ui.actions.NaturalVariableFormatActionDelegate">
</action>
</objectContribution>
<viewerContribution
targetID="org.eclipse.cdt.debug.ui.SharedLibrariesView"
id="org.eclipse.cdt.debug.ui.SharedLibrariesViewPopupActions">
<action
helpContextId="load_symbols_for_all_context"
label="%LoadSymbolsForAllAction.label"
tooltip="%LoadSymbolsForAllAction.tooltip"
icon="icons/full/elcl16/load_all_symbols_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate"
style="push"
menubarPath="sharedLibrariesGroup"
id="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
</viewerContribution>
<objectContribution
objectClass="org.eclipse.cdt.debug.core.model.ICSharedLibrary"
id="org.eclipse.cdt.debug.ui.SharedLibraryActions">
<action
label="%LoadSymbolsAction.label"
icon="icons/full/clcl16/load_symbols_co.gif"
helpContextId="load_symbols_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsActionDelegate"
tooltip="%LoadSymbolsAction.tooltip"
menubarPath="sharedLibrariesGroup"
enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui">
</pluginState>
</enablement>
</action>
</objectContribution>
<objectContribution
objectClass="org.eclipse.cdt.debug.core.model.ICSignal"
id="org.eclipse.cdt.debug.ui.SignalActions">
@ -897,41 +842,6 @@
</enablement>
</action>
</viewContribution>
<viewContribution
targetID="org.eclipse.cdt.debug.ui.SharedLibrariesView"
id="org.eclipse.debug.ui.sharedLibrariesView.menu">
<action
label="%ShowFullPathsAction.label"
style="toggle"
icon="icons/full/clcl16/show_paths.gif"
helpContextId="show_full_paths_context"
class="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction"
tooltip="%ShowFullPathsAction.tooltip"
menubarPath="cDebugActions"
id="org.eclipse.cdt.debug.internal.ui.actions.ShowFullPathsAction">
</action>
</viewContribution>
<viewContribution
targetID="org.eclipse.cdt.debug.ui.SharedLibrariesView"
id="org.eclipse.debug.ui.sharedLibrariesView.toolbar">
<action
helpContextId="load_symbols_for_all_context"
disabledIcon="icons/full/dlcl16/load_all_symbols_co.gif"
hoverIcon="icons/full/clcl16/load_all_symbols_co.gif"
toolbarPath="sharedLibrariesGroupLoadSymbolsForAllAction.label"
label="%LoadSymbolsForAllAction.label"
tooltip="%LoadSymbolsForAllAction.tooltip"
icon="icons/full/elcl16/load_all_symbols_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate"
style="push"
id="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
</viewContribution>
<viewContribution
targetID="org.eclipse.debug.ui.RegisterView"
id="org.eclipse.debug.ui.registersView.toolbar">
@ -1116,10 +1026,6 @@
viewId="org.eclipse.debug.ui.MemoryView"
contextId="org.eclipse.cdt.debug.ui.debugging">
</contextViewBinding>
<contextViewBinding
viewId="org.eclipse.cdt.debug.ui.SharedLibrariesView"
contextId="org.eclipse.cdt.debug.ui.debugging">
</contextViewBinding>
<contextViewBinding
viewId="org.eclipse.cdt.debug.ui.SignalsView"
contextId="org.eclipse.cdt.debug.ui.debugging">

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.internal.ui;
import java.text.MessageFormat;
import java.util.HashMap;
import org.eclipse.cdt.core.resources.FileStorage;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
@ -33,7 +32,6 @@ import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.cdt.debug.core.model.ICSignal;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.ICThread;
@ -244,9 +242,6 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
if ( element instanceof IVariable ) {
return getVariableImage( (IVariable)element );
}
if ( element instanceof ICSharedLibrary ) {
return getSharedLibraryImage( (ICSharedLibrary)element );
}
if ( element instanceof ICModule ) {
return getModuleImage( (ICModule)element );
}
@ -334,10 +329,6 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
boolean showQualified = isShowQualifiedNames();
StringBuffer label = new StringBuffer();
try {
if ( element instanceof ICSharedLibrary ) {
label.append( getSharedLibraryText( (ICSharedLibrary)element, showQualified ) );
return label.toString();
}
if ( element instanceof ICModule ) {
label.append( getModuleText( (ICModule)element, showQualified ) );
return label.toString();
@ -404,20 +395,6 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return getDefaultText( element );
}
protected String getSharedLibraryText( ICSharedLibrary library, boolean qualified ) {
String label = new String();
String name = library.getFileName();
if ( !isEmpty( name ) ) {
IPath path = new Path( library.getFileName() );
if ( !path.isEmpty() )
label += ( qualified ? path.toOSString() : path.lastSegment() );
}
else {
label += CDebugUIMessages.getString( "CDebugModelPresentation.unknown_1" ); //$NON-NLS-1$
}
return label;
}
protected String getModuleText( ICModule module, boolean qualified ) {
StringBuffer sb = new StringBuffer();
IPath path = module.getImageName();
@ -455,10 +432,6 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return this.fImageCache;
}
private CDebugImageDescriptorRegistry getDebugImageRegistry() {
return this.fDebugImageRegistry;
}
private boolean isEmpty( String string ) {
return ( string == null || string.trim().length() == 0 );
}
@ -653,16 +626,6 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ) );
}
protected Image getSharedLibraryImage( ICSharedLibrary element ) {
if ( element.areSymbolsLoaded() ) {
return getImageCache().getImageFor(
new OverlayImageDescriptor( getDebugImageRegistry().get( CDebugImages.DESC_OBJS_SHARED_LIBRARY_WITH_SYMBOLS ),
new ImageDescriptor[] { null, CDebugImages.DESC_OVRS_SYMBOLS, null, null } ) );
}
return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_SHARED_LIBRARY );
}
protected Image getModuleImage( ICModule element ) {
switch( element.getType() ) {
case ICModule.EXECUTABLE:

View file

@ -1,110 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 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.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
/**
* Enter type comment.
*
* @since: Jan 17, 2003
*/
public class LoadSymbolsActionDelegate implements IObjectActionDelegate {
private ICSharedLibrary fLibrary;
/**
* Constructor for LoadSymbolsActionDelegate.
*/
public LoadSymbolsActionDelegate() {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
*/
public void setActivePart( IAction action, IWorkbenchPart targetPart ) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run( IAction action ) {
final ICSharedLibrary library = getSharedLibrary();
if ( library != null ) {
DebugPlugin.getDefault().asyncExec(
new Runnable() {
public void run() {
try {
doAction( getSharedLibrary() );
}
catch( DebugException e ) {
failed( e );
}
}
} );
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.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;
}
protected void failed( Throwable e ) {
MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, ActionMessages.getString( "LoadSymbolsActionDelegate.Operation_failed_1" ), null ); //$NON-NLS-1$
ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ) );
CDebugUtils.error( ms, this );
}
}

View file

@ -24,7 +24,7 @@ import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.jface.action.IAction;
/**
* The delegate for the "Load Symbols For All" action of the Shared Libraries view.
* The delegate for the "Load Symbols For All" action of the Modules view.
*/
public class LoadSymbolsForAllActionDelegate extends AbstractViewActionDelegate {
@ -53,7 +53,7 @@ public class LoadSymbolsForAllActionDelegate extends AbstractViewActionDelegate
public void run() {
try {
target.loadSymbols();
target.loadSymbolsForAllModules();
}
catch( DebugException e ) {
failed( e );

View file

@ -1,34 +0,0 @@
/**********************************************************************
* 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.views.sharedlibs;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class SharedLibrariesMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.sharedlibs.SharedLibrariesMessages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
private SharedLibrariesMessages() {
}
public static String getString( String key ) {
try {
return RESOURCE_BUNDLE.getString( key );
}
catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View file

@ -1,17 +0,0 @@
###############################################################################
# Copyright (c) 2003, 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
###############################################################################
SharedLibrariesView.Name_1=Name
SharedLibrariesView.Start_Address_1=Start Address
SharedLibrariesView.End_Address_1=End Address
SharedLibrariesView.Loaded_1=Loaded
SharedLibrariesView.Not_loaded_1=Not loaded
SharedLibrariesView.Symbols_1=Symbols

View file

@ -1,281 +0,0 @@
/**********************************************************************
* 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.views.sharedlibs;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.cdt.debug.internal.ui.CDebugModelPresentation;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
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.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.ui.IDebugModelPresentation;
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.IBaseLabelProvider;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableTreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.INullSelectionListener;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
/**
* Displays shared libraries.
*/
public class SharedLibrariesView extends AbstractDebugEventHandlerView
implements ISelectionListener,
INullSelectionListener,
IPropertyChangeListener,
IDebugExceptionHandler {
public class SharedLibrariesLabelProvider extends CDebugModelPresentation implements ITableLabelProvider {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/
public Image getColumnImage( Object element, int columnIndex ) {
if ( element instanceof ICSharedLibrary && columnIndex == 1 )
return getImage( element );
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
public String getColumnText( Object element, int columnIndex ) {
if ( element instanceof ICSharedLibrary ) {
ICSharedLibrary library = (ICSharedLibrary)element;
switch( columnIndex ) {
case 0:
return ""; //$NON-NLS-1$
case 1:
return getText( element );
case 2:
return ( library.areSymbolsLoaded() ) ? SharedLibrariesMessages.getString( "SharedLibrariesView.Loaded_1" ) : SharedLibrariesMessages.getString( "SharedLibrariesView.Not_loaded_1" ); //$NON-NLS-1$ //$NON-NLS-2$
case 3:
return library.getStartAddress().toHexAddressString(); //$NON-NLS-1$
case 4:
return library.getEndAddress().toHexAddressString(); //$NON-NLS-1$
}
}
return null;
}
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite)
*/
protected Viewer createViewer( Composite parent ) {
TableTreeViewer viewer = new TableTreeViewer( parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
Table table = viewer.getTableTree().getTable();
table.setLinesVisible( true );
table.setHeaderVisible( true );
// Create the table columns
new TableColumn( table, SWT.NULL );
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[1].setResizable( true );
columns[2].setResizable( true );
columns[3].setResizable( true );
columns[4].setResizable( true );
columns[0].setText( "" ); //$NON-NLS-1$
columns[1].setText( SharedLibrariesMessages.getString( "SharedLibrariesView.Name_1" ) ); //$NON-NLS-1$
columns[2].setText( SharedLibrariesMessages.getString( "SharedLibrariesView.Symbols_1" ) ); //$NON-NLS-1$
columns[3].setText( SharedLibrariesMessages.getString( "SharedLibrariesView.Start_Address_1" ) ); //$NON-NLS-1$
columns[4].setText( SharedLibrariesMessages.getString( "SharedLibrariesView.End_Address_1" ) ); //$NON-NLS-1$
PixelConverter pc = new PixelConverter( parent );
columns[0].setWidth( pc.convertWidthInCharsToPixels( 3 ) );
columns[1].setWidth( pc.convertWidthInCharsToPixels( 50 ) );
columns[2].setWidth( pc.convertWidthInCharsToPixels( 20 ) );
columns[3].setWidth( pc.convertWidthInCharsToPixels( 20 ) );
columns[4].setWidth( pc.convertWidthInCharsToPixels( 20 ) );
viewer.setContentProvider( createContentProvider() );
viewer.setLabelProvider( new SharedLibrariesLabelProvider() );
CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this );
// 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() {
}
/* (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( ICDebugUIConstants.EMPTY_SHARED_LIBRARIES_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.SHARED_LIBRARIES_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.EMPTY_REFRESH_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.REFRESH_GROUP ) );
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
updateObjects();
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractDebugView#configureToolBar(IToolBarManager)
*/
protected void configureToolBar( IToolBarManager tbm ) {
tbm.add( new Separator( ICDebugUIConstants.SHARED_LIBRARIES_GROUP ) );
tbm.add( new Separator( ICDebugUIConstants.REFRESH_GROUP ) );
}
/* (non-Javadoc)
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
*/
public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
if ( !isAvailable() || !isVisible() )
return;
if ( selection == null )
setViewerInput( new StructuredSelection() );
else 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 ) {
showMessage( e.getMessage() );
}
protected void setViewerInput( IStructuredSelection ssel ) {
ICDebugTarget target = null;
if ( ssel != null && ssel.size() == 1 ) {
Object input = ssel.getFirstElement();
if ( input instanceof IDebugElement && ((IDebugElement)input).getDebugTarget() instanceof ICDebugTarget )
target = (ICDebugTarget)((IDebugElement)input).getDebugTarget();
}
if ( getViewer() == null )
return;
Object current = getViewer().getInput();
if ( current != null && current.equals( target ) ) {
updateObjects();
return;
}
showViewer();
getViewer().setInput( target );
updateObjects();
}
/**
* 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 );
}
/**
* Creates this view's content provider.
*
* @return a content provider
*/
protected IContentProvider createContentProvider() {
SharedLibrariesViewContentProvider cp = new SharedLibrariesViewContentProvider();
cp.setExceptionHandler( this );
return cp;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractDebugView#becomesHidden()
*/
protected void becomesHidden() {
setViewerInput( new StructuredSelection() );
super.becomesHidden();
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractDebugView#becomesVisible()
*/
protected void becomesVisible() {
super.becomesVisible();
IViewPart part = getSite().getPage().findView( IDebugUIConstants.ID_DEBUG_VIEW );
if ( part != null ) {
ISelection selection = getSite().getPage().getSelection( IDebugUIConstants.ID_DEBUG_VIEW );
selectionChanged( part, selection );
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPart#dispose()
*/
public void dispose() {
getSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this );
super.dispose();
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDebugView#getPresentation(java.lang.String)
*/
public IDebugModelPresentation getPresentation( String id ) {
StructuredViewer viewer = getStructuredViewer();
if ( viewer != null ) {
IBaseLabelProvider lp = viewer.getLabelProvider();
return ( lp instanceof SharedLibrariesLabelProvider ) ? (SharedLibrariesLabelProvider)lp : null;
}
return null;
}
}

View file

@ -1,191 +0,0 @@
/**********************************************************************
* 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.views.sharedlibs;
import java.util.HashMap;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
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.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
/**
* Provides content for the shared libraries view.
*
* @since: Jan 21, 2003
*/
public class SharedLibrariesViewContentProvider implements ITreeContentProvider {
/**
* A table that maps children to their parent element such that this
* content provider can walk back up the parent chain (since values do not
* know their parent). Map of <code>IVariable</code> (child) -><code>IVariable</code>
* (parent).
*/
private HashMap fParentCache;
/**
* Handler for exceptions as content is retrieved
*/
private IDebugExceptionHandler fExceptionHandler;
/**
* Constructor for SharedLibrariesViewContentProvider.
*/
public SharedLibrariesViewContentProvider() {
setParentCache( new HashMap( 10 ) );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object)
*/
public Object[] getChildren( Object parent ) {
if ( parent instanceof ICDebugTarget ) {
Object[] children = null;
ICDebugTarget target = (ICDebugTarget)parent;
try {
if ( target != null )
children = target.getSharedLibraries();
if ( children != null ) {
cache( parent, children );
return children;
}
}
catch( DebugException e ) {
if ( getExceptionHandler() != null )
getExceptionHandler().handleException( e );
else
CDebugUIPlugin.log( e );
}
}
return new Object[0];
}
/**
* Caches the given elememts as children of the given parent.
*
* @param parent
* parent element
* @param children
* children elements
*/
protected void cache( Object parent, Object[] children ) {
for ( int i = 0; i < children.length; i++ ) {
getParentCache().put( children[i], parent );
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(Object)
*/
public Object getParent( Object element ) {
return getParentCache().get( element );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(Object)
*/
public boolean hasChildren( Object parent ) {
if ( parent instanceof ICDebugTarget ) {
try {
ICDebugTarget target = (ICDebugTarget)parent;
return target.hasSharedLibraries();
}
catch( DebugException e ) {
CDebugUIPlugin.log( e );
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object)
*/
public Object[] getElements( Object inputElement ) {
return getChildren( inputElement );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
setParentCache( null );
setExceptionHandler( null );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer,
* Object, Object)
*/
public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
clearCache();
}
protected void clearCache() {
if ( getParentCache() != null ) {
getParentCache().clear();
}
}
/**
* Remove the cached parent for the given children
*
* @param children
* for which to remove cached parents
*/
public void removeCache( Object[] children ) {
if ( getParentCache() != null ) {
for ( int i = 0; i < children.length; i++ ) {
getParentCache().remove( children[i] );
}
}
}
/**
* Sets an exception handler for this content provider.
*
* @param handler debug exception handler or <code>null</code>
*/
protected void setExceptionHandler( IDebugExceptionHandler handler ) {
this.fExceptionHandler = handler;
}
/**
* Returns the exception handler for this content provider.
*
* @return debug exception handler or <code>null</code>
*/
protected IDebugExceptionHandler getExceptionHandler() {
return this.fExceptionHandler;
}
private HashMap getParentCache() {
return this.fParentCache;
}
private void setParentCache( HashMap parentCache ) {
this.fParentCache = parentCache;
}
}

View file

@ -1,80 +0,0 @@
/**********************************************************************
* 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.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.model.IDebugTarget;
import org.eclipse.debug.ui.AbstractDebugView;
/**
* Updates the shared libraries view.
*
* @since: Jan 21, 2003
*/
public class SharedLibrariesViewEventHandler extends AbstractDebugEventHandler {
/**
* Constructs a new event handler on the given view
*
* @param view shared libraries 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];
switch( event.getKind() ) {
case DebugEvent.CREATE:
case DebugEvent.TERMINATE:
if ( event.getSource() instanceof IDebugTarget || event.getSource() instanceof ICSharedLibrary )
refresh();
break;
case DebugEvent.CHANGE :
if ( event.getSource() instanceof ICSharedLibrary )
refresh( event.getSource() );
break;
}
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler#refresh()
*/
public void refresh() {
if ( isAvailable() ) {
getView().showViewer();
getTableTreeViewer().refresh();
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler#refresh(java.lang.Object)
*/
protected void refresh( Object element ) {
if ( isAvailable() ) {
getView().showViewer();
getTableTreeViewer().refresh( element );
}
}
}

View file

@ -59,21 +59,6 @@ public interface ICDebugUIConstants {
*/
public static final String REFRESH_GROUP = "refreshGroup"; //$NON-NLS-1$
/**
* Identifier for an empty group preceeding a
* shared libraries group in a menu (value <code>"
* emptySharedLibrariesGroup"
* </code>).
*/
public static final String EMPTY_SHARED_LIBRARIES_GROUP = "emptySharedLibrariesGroup"; //$NON-NLS-1$
/**
* Identifier for a shared libraries group in a menu (value <code>"
* sharedLibrariesGroup"
* </code>).
*/
public static final String SHARED_LIBRARIES_GROUP = "sharedLibrariesGroup"; //$NON-NLS-1$
/**
* Identifier for an empty group preceeding a
* modules group in a menu (value <code>"emptyModulesGroup"</code>).