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

Bug 82264: Enhance the Shared Libraries view. Implementing module's properties.

This commit is contained in:
Mikhail Khodjaiants 2005-02-12 00:09:10 +00:00
parent e1e52bf692
commit 6bb8abd4e9
10 changed files with 493 additions and 10 deletions

View file

@ -1,3 +1,16 @@
2005-02-11 Mikhail Khodjaiants
Bug 82264: Enhance the Shared Libraries view.
Implementing module's properties.
* CDebugModelPresentation.java
* CDebugUIMessages.properties
* ModulesPropertiesActionDelegate.java: new
* CModuleProperties.java: new
* ModulePropertyPage.java: new
* ModulesMessages.properties
* ModulesView.java
* plugin.xml
* plugin.properties
2005-02-08 Mikhail Khodjaiants
Bug 82264: Enhance the Shared Libraries view.
Improved detail information.

View file

@ -117,9 +117,13 @@ DebuggingCContext.description=Debugging C/C++ Programs
CommonBreakpointPage.label=Common
FilteringBreakpointPage.label=Filtering
CommonSignalPage.label=Common
CommonModulePage.label=Common
ModulesDetailPaneFontDefinition.label=Modules View Detail Pane Text Font
ModulesDetailPaneFontDefinition.description=The text font used in the detail pane of the Modules view.
CollapseAllModulesAction.label=Collapse All
CollapseAllModulesAction.tooltip=Collapse All
ModulePropertiesAction.label=Module Properties...
ModulePropertiesAction.tooltip=Open Module Properties Dialog

View file

@ -729,6 +729,24 @@
menubarPath="additions"
id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate"/>
</viewerContribution>
<objectContribution
objectClass="org.eclipse.cdt.debug.core.model.ICModule"
id="org.eclipse.cdt.debug.ui.ModuleActions">
<action
helpContextId="module_properties_action_context"
enablesFor="1"
label="%ModulePropertiesAction.label"
tooltip="%ModulePropertiesAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.ModulesPropertiesActionDelegate"
style="pulldown"
id="org.eclipse.cdt.debug.ui.ModulePropertiesAction">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui.pluginState1"/>
</enablement>
</action>
</objectContribution>
</extension>
<extension
point="org.eclipse.ui.viewActions">
@ -1006,6 +1024,11 @@
class="org.eclipse.cdt.debug.internal.ui.propertypages.SignalPropertyPage"
name="%CommonSignalPage.label"
id="org.eclipse.cdt.debug.ui.propertypages.signal.common"/>
<page
objectClass="org.eclipse.cdt.debug.core.model.ICModule"
class="org.eclipse.cdt.debug.internal.ui.propertypages.ModulePropertyPage"
name="%CommonModulePage.label"
id="org.eclipse.cdt.debug.ui.propertypages.module.common"/>
</extension>
<extension
id="org.eclipse.cdt.debug.ui.editors"
@ -1067,7 +1090,7 @@
</contextViewBinding>
<contextViewBinding
contextId="org.eclipse.cdt.debug.ui.debugging"
viewId="org.eclipse.debug.ui.MemoryView"/>
viewId="org.eclipse.cdt.debug.ui.ModulesView"/>
</extension>
<extension
point="org.eclipse.ui.editors.annotationTypes">

View file

@ -427,7 +427,6 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
else {
sb.append( CDebugUIMessages.getString( "CDebugModelPresentation.unknown_1" ) ); //$NON-NLS-1$
}
sb.append( ( module.areSymbolsLoaded() ) ? CDebugUIMessages.getString( "CDebugModelPresentation.0" ) : CDebugUIMessages.getString( "CDebugModelPresentation.1" ) ); //$NON-NLS-1$ //$NON-NLS-2$
return sb.toString();
}

View file

@ -10,8 +10,6 @@
###############################################################################
CDebugModelPresentation.unknown_1=unknown
CDebugModelPresentation.0=\ (symbols loaded)
CDebugModelPresentation.1=\ (symbols not loaded)
CDebugImageDescriptorRegistry.0=Allocating image for wrong display.
CDebugModelPresentation.not_available_1=<not available>
CDTDebugModelPresentation.0=<terminated>

View file

@ -0,0 +1,91 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.ui.dialogs.PropertyDialogAction;
/**
* Module Properties action delegate.
*/
public class ModulesPropertiesActionDelegate extends ActionDelegate implements IObjectActionDelegate {
private ICModule fModule;
/**
* Constructor for ModulesPropertiesActionDelegate.
*/
public ModulesPropertiesActionDelegate() {
super();
}
protected ICModule getModule() {
return fModule;
}
private void setModule( ICModule module ) {
fModule = module;
}
/* (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 ) {
PropertyDialogAction propertyAction = new PropertyDialogAction( CDebugUIPlugin.getActiveWorkbenchShell(), new ISelectionProvider() {
public void addSelectionChangedListener( ISelectionChangedListener listener ) {
}
public ISelection getSelection() {
return new StructuredSelection( getModule() );
}
public void removeSelectionChangedListener( ISelectionChangedListener listener ) {
}
public void setSelection( ISelection selection ) {
}
} );
propertyAction.run();
}
/* (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 ICModule ) {
action.setEnabled( true );
setModule( (ICModule)element );
return;
}
}
action.setEnabled( false );
setModule( null );
}
}

View file

@ -0,0 +1,55 @@
/**********************************************************************
* 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.propertypages;
import java.util.HashMap;
import org.eclipse.cdt.debug.core.model.ICModule;
/**
* A module's properties store.
*/
public class CModuleProperties {
final static public String TYPE = "type"; //$NON-NLS-1$
final static public String CPU = "cpu"; //$NON-NLS-1$
final static public String BASE_ADDRESS = "baseAddress"; //$NON-NLS-1$
final static public String SIZE = "size"; //$NON-NLS-1$
final static public String SYMBOLS_LOADED = "symbolsLoaded"; //$NON-NLS-1$
final static public String SYMBOLS_FILE = "symbolsFile"; //$NON-NLS-1$
private HashMap fMap;
static CModuleProperties create( ICModule module ) {
CModuleProperties p = new CModuleProperties();
p.setProperty( TYPE, new Integer( module.getType() ) );
p.setProperty( CPU, module.getCPU() );
p.setProperty( BASE_ADDRESS, module.getBaseAddress() );
p.setProperty( SIZE, new Long( module.getSize() ) );
p.setProperty( SYMBOLS_LOADED, new Boolean( module.areSymbolsLoaded() ) );
p.setProperty( SYMBOLS_FILE, module.getSymbolsFileName() );
return p;
}
/**
* Constructor for CModuleProperties.
*/
private CModuleProperties() {
fMap = new HashMap( 5 );
}
private void setProperty( String key, Object value ) {
fMap.put( key, value );
}
public Object[] getProperties() {
return fMap.entrySet().toArray();
}
}

View file

@ -0,0 +1,208 @@
/**********************************************************************
* 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.propertypages;
import java.util.Map;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.IStructuredContentProvider;
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.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.dialogs.PropertyPage;
/**
* The property page for a module.
*/
public class ModulePropertyPage extends PropertyPage {
public class ModulePropertyLabelProvider extends LabelProvider implements ITableLabelProvider {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/
public Image getColumnImage( Object element, int columnIndex ) {
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 Map.Entry ) {
Map.Entry entry = (Map.Entry)element;
if ( CModuleProperties.TYPE.equals( entry.getKey() ) ) {
if ( columnIndex == 0 ) {
return "Type";
}
else {
Integer type = (Integer)entry.getValue();
if ( type.intValue() == ICModule.EXECUTABLE ) {
return "executable";
}
if ( type.intValue() == ICModule.SHARED_LIBRARY ) {
return "shared library";
}
if ( type.intValue() == ICModule.CORE ) {
return "core file";
}
}
}
else if ( CModuleProperties.CPU.equals( entry.getKey() ) ) {
if ( columnIndex == 0 ) {
return "CPU";
}
String cpu = (String)entry.getValue();
return ( cpu != null ) ? cpu : "not available";
}
else if ( CModuleProperties.BASE_ADDRESS.equals( entry.getKey() ) ) {
if ( columnIndex == 0 ) {
return "Base address";
}
IAddress address = (IAddress)entry.getValue();
return ( address != null && !address.isZero() ) ? address.toHexAddressString() : "not available";
}
else if ( CModuleProperties.SIZE.equals( entry.getKey() ) ) {
if ( columnIndex == 0 ) {
return "Size";
}
Long size = (Long)entry.getValue();
return ( size != null && size.longValue() > 0 ) ? size.toString() : "not available";
}
else if ( CModuleProperties.SYMBOLS_LOADED.equals( entry.getKey() ) ) {
if ( columnIndex == 0 ) {
return "Symbols";
}
Boolean loaded = (Boolean)entry.getValue();
return ( loaded != null && loaded.booleanValue() ) ? "loaded" : "not loaded";
}
else if ( CModuleProperties.SYMBOLS_FILE.equals( entry.getKey() ) ) {
if ( columnIndex == 0 ) {
return "Symbols file";
}
IPath path = (IPath)entry.getValue();
return ( path != null ) ? path.toOSString() : "not found";
}
}
return null;
}
}
public class ModulePropertyContentProvider implements IStructuredContentProvider {
/**
* Constructor for ModulePropertyContentProvider.
*/
public ModulePropertyContentProvider() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements( Object inputElement ) {
if ( inputElement instanceof ICModule ) {
return CModuleProperties.create( (ICModule)inputElement ).getProperties();
}
return new Object[0];
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
}
}
private TableViewer fViewer;
// Column properties
private static final String CP_NAME = "name"; //$NON-NLS-1$
private static final String CP_VALUE = "value"; //$NON-NLS-1$
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
protected Control createContents( Composite parent ) {
noDefaultAndApplyButton();
Composite composite = new Composite( parent, SWT.NONE );
Font font = parent.getFont();
composite.setFont( font );
composite.setLayout( new GridLayout() );
composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
fViewer = new TableViewer( composite, SWT.BORDER );
Table table = fViewer.getTable();
table.setLinesVisible( true );
table.setHeaderVisible( true );
table.setLayoutData( new GridData( GridData.FILL_BOTH ) );
// Create the table columns
new TableColumn( table, SWT.NULL );
new TableColumn( table, SWT.NULL );
TableColumn[] columns = table.getColumns();
columns[0].setResizable( true );
columns[1].setResizable( true );
PixelConverter pc = new PixelConverter( parent );
columns[0].setWidth( pc.convertWidthInCharsToPixels( 15 ) );
columns[1].setWidth( pc.convertWidthInCharsToPixels( 40 ) );
fViewer.setColumnProperties( new String[]{ CP_NAME, CP_VALUE } );
fViewer.setContentProvider( createContentProvider() );
fViewer.setLabelProvider( createLabelProvider() );
setValid( true );
return composite;
}
protected ICModule getModule() {
return (ICModule)getElement();
}
private ModulePropertyContentProvider createContentProvider() {
return new ModulePropertyContentProvider();
}
private ModulePropertyLabelProvider createLabelProvider() {
return new ModulePropertyLabelProvider();
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl( Composite parent ) {
super.createControl( parent );
getViewer().setInput( getElement() );
}
private TableViewer getViewer() {
return fViewer;
}
}

View file

@ -1,6 +1,8 @@
ModulesView.0=Modules View Only
ModulesView.1=executable
ModulesView.10=Size:
ModulesView.11=\ (symbols loaded)
ModulesView.12=(symbols not loaded)
ModulesView.2=shared library
ModulesView.3=Type:
ModulesView.4=Symbols:

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.internal.ui.views.modules;
import java.util.HashMap;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.debug.core.model.ICDebugElement;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
@ -24,6 +23,7 @@ import org.eclipse.cdt.debug.internal.ui.actions.ToggleDetailPaneAction;
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
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.AbstractViewerState;
import org.eclipse.cdt.debug.internal.ui.views.DebugViewDecoratingLabelProvider;
import org.eclipse.cdt.debug.internal.ui.views.DebugViewInterimLabelProvider;
import org.eclipse.cdt.debug.internal.ui.views.DebugViewLabelDecorator;
@ -32,9 +32,10 @@ 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.DebugPlugin;
import org.eclipse.cdt.debug.internal.ui.views.AbstractViewerState;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IValueDetailListener;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@ -55,6 +56,7 @@ import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@ -72,11 +74,13 @@ import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.INullSelectionListener;
import org.eclipse.ui.ISelectionListener;
@ -93,6 +97,90 @@ import org.eclipse.ui.texteditor.IUpdate;
*/
public class ModulesView extends AbstractDebugEventHandlerView implements IDebugExceptionHandler, IPropertyChangeListener, ISelectionListener, INullSelectionListener {
class ModulesViewModelPresentation implements IDebugModelPresentation {
private CDebugModelPresentation fDelegate;
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDebugModelPresentation#setAttribute(java.lang.String, java.lang.Object)
*/
public void setAttribute( String attribute, Object value ) {
getModelPresentation().setAttribute( attribute, value );
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
*/
public Image getImage( Object element ) {
return getModelPresentation().getImage( element );
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
public String getText( Object element ) {
String text = getModelPresentation().getText( element );
if ( element instanceof ICModule ) {
ICModule module = (ICModule)element;
text += ( module.areSymbolsLoaded() ) ? ModulesMessages.getString( "ModulesView.11" ) : ModulesMessages.getString( "ModulesView.12" ); //$NON-NLS-1$ //$NON-NLS-2$
}
return text;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.IDebugModelPresentation#computeDetail(org.eclipse.debug.core.model.IValue, org.eclipse.debug.ui.IValueDetailListener)
*/
public void computeDetail( IValue value, IValueDetailListener listener ) {
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(java.lang.Object)
*/
public IEditorInput getEditorInput( Object element ) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(org.eclipse.ui.IEditorInput, java.lang.Object)
*/
public String getEditorId( IEditorInput input, Object element ) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
*/
public void addListener( ILabelProviderListener listener ) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
*/
public void dispose() {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
*/
public boolean isLabelProperty( Object element, String property ) {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
*/
public void removeListener( ILabelProviderListener listener ) {
}
private CDebugModelPresentation getModelPresentation() {
if ( fDelegate == null ) {
fDelegate = CDebugModelPresentation.getDefault();
}
return fDelegate;
}
}
/**
* Internal interface for a cursor listener. I.e. aggregation
* of mouse and key listener.
@ -424,7 +512,7 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
protected IDebugModelPresentation getModelPresentation() {
if ( fModelPresentation == null ) {
fModelPresentation = CDebugModelPresentation.getDefault();
fModelPresentation = new ModulesViewModelPresentation();
}
return fModelPresentation;
}
@ -814,12 +902,14 @@ public class ModulesView extends AbstractDebugEventHandlerView implements IDebug
sb.append( module.getSymbolsFileName().toOSString() );
sb.append( '\n' );
}
IBinary binary = (IBinary)module.getAdapter( IBinary.class );
if ( binary != null ) {
String cpu = module.getCPU();
if ( cpu != null ) {
sb.append( ModulesMessages.getString( "ModulesView.8" ) ); //$NON-NLS-1$
sb.append( binary.getCPU() );
sb.append( cpu );
sb.append( '\n' );
}
IAddress baseAddress = module.getBaseAddress();
if ( !baseAddress.isZero() ) {
sb.append( ModulesMessages.getString( "ModulesView.9" ) ); //$NON-NLS-1$