diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 2e34be7a2ca..2f2447eecbd 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,28 @@ +2005-02-07 Mikhail Khodjaiants + Bug 82264: Enhance the Shared Libraries view. + * CDebugUIMessages.properties + * CDebugImages.java + * CDebugModelPresentation.java + * CDTDebugModelPresentation.java: removed + * ICDebugHelpContextIds.java + * ActionMessages.properties + * CollapseAllModulesAction.java: new + * ToggleDetailPaneAction.java: new + * ICDebugPreferenceConstants.java + * DebugViewDecoratingLabelProvider.java: new + * DebugViewInterimLabelProvider.java: new + * DebugViewLabelDecorator.java: new + * org.eclipse.cdt.debug.internal.ui.views.modules: new package + * ModulesMessages.properties: new + * ModulesMessages.java: new + * ModulesView.java: new + * ModulesViewContentProvider.java: new + * ModulesViewer.java: new + * ModulesViewEventHandler.java: new + * CDebugUIPlugin.java + * plugin.xml + * plugin.properties + 2005-02-07 Mikhail Khodjaiants Added images for the "Collapse All" action of the modules view. * icons\full\clcl16\collapseall.gif diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index 0c528f4cb8c..14a69a5755a 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -14,6 +14,7 @@ providerName=Eclipse.org MemoryView.name=Memory SharedLibrariesView.name=Shared Libraries +ModulesView.name=Modules SignalsView.name=Signals CDebuggerPage.name=C Debugger UI Page @@ -116,3 +117,6 @@ DebuggingCContext.description=Debugging C/C++ Programs CommonBreakpointPage.label=Common FilteringBreakpointPage.label=Filtering CommonSignalPage.label=Common + +CollapseAllModulesAction.label=Collapse All +CollapseAllModulesAction.tooltip=Collapse All diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index 982600dc833..16d43b908a3 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -34,7 +34,7 @@ @@ -61,6 +61,12 @@ class="org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView" id="org.eclipse.cdt.debug.ui.DisassemblyView"> + @@ -102,6 +108,12 @@ + + + + + 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 deleted file mode 100644 index eabe4b50530..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java +++ /dev/null @@ -1,914 +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; - -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; -import org.eclipse.cdt.debug.core.cdi.ICDIExitInfo; -import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryEvent; -import org.eclipse.cdt.debug.core.cdi.ICDISignalExitInfo; -import org.eclipse.cdt.debug.core.cdi.ICDISignalReceived; -import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointScope; -import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger; -import org.eclipse.cdt.debug.core.cdi.model.ICDISignal; -import org.eclipse.cdt.debug.core.model.CDebugElementState; -import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; -import org.eclipse.cdt.debug.core.model.ICBreakpoint; -import org.eclipse.cdt.debug.core.model.ICDebugElement; -import org.eclipse.cdt.debug.core.model.ICDebugElementStatus; -import org.eclipse.cdt.debug.core.model.ICDebugTarget; -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.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; -import org.eclipse.cdt.debug.core.model.ICType; -import org.eclipse.cdt.debug.core.model.ICValue; -import org.eclipse.cdt.debug.core.model.ICVariable; -import org.eclipse.cdt.debug.core.model.ICWatchpoint; -import org.eclipse.cdt.debug.core.model.IDummyStackFrame; -import org.eclipse.cdt.debug.core.model.IEnableDisableTarget; -import org.eclipse.cdt.debug.internal.ui.editors.CDebugEditor; -import org.eclipse.cdt.debug.internal.ui.editors.EditorInputDelegate; -import org.eclipse.cdt.debug.internal.ui.editors.FileNotFoundElement; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.cdt.internal.ui.util.ExternalEditorInput; -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.model.IBreakpoint; -import org.eclipse.debug.core.model.IDebugTarget; -import org.eclipse.debug.core.model.IDisconnect; -import org.eclipse.debug.core.model.IExpression; -import org.eclipse.debug.core.model.IRegister; -import org.eclipse.debug.core.model.IRegisterGroup; -import org.eclipse.debug.core.model.IStackFrame; -import org.eclipse.debug.core.model.ITerminate; -import org.eclipse.debug.core.model.IThread; -import org.eclipse.debug.core.model.IValue; -import org.eclipse.debug.core.model.IVariable; -import org.eclipse.debug.core.model.IWatchExpression; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugModelPresentation; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.IValueDetailListener; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.FileEditorInput; - -/** - * Responsible for providing labels, images, and editors associated with debug elements in the CDT debug model. - */ -public class CDTDebugModelPresentation extends LabelProvider implements IDebugModelPresentation { - - /** - * Qualified names presentation property (value "org.eclipse.debug.ui.displayQualifiedNames"). When DISPLAY_QUALIFIED_NAMES - * is set to True, this label provider should use fully qualified type names when rendering elements. When set to False ,this - * label provider should use simple names when rendering elements. - * - * @see #setAttribute(String, Object) - */ - public final static String DISPLAY_FULL_PATHS = "DISPLAY_FULL_PATHS"; //$NON-NLS-1$ - - private static final String DUMMY_STACKFRAME_LABEL = "..."; //$NON-NLS-1$ - - protected HashMap fAttributes = new HashMap( 3 ); - - protected CDebugImageDescriptorRegistry fDebugImageRegistry = CDebugUIPlugin.getImageDescriptorRegistry(); - - private static CDTDebugModelPresentation fInstance = null; - - private OverlayImageCache fImageCache = new OverlayImageCache(); - - /** - * Constructor for CDTDebugModelPresentation. - */ - public CDTDebugModelPresentation() { - super(); - fInstance = this; - } - - public static CDTDebugModelPresentation getDefault() { - return fInstance; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.ui.IDebugModelPresentation#setAttribute(String, Object) - */ - public void setAttribute( String attribute, Object value ) { - if ( value != null ) { - fAttributes.put( attribute, value ); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.ui.IDebugModelPresentation#computeDetail(IValue, IValueDetailListener) - */ - public void computeDetail( IValue value, IValueDetailListener listener ) { - CValueDetailProvider.getDefault().computeDetail( value, listener ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(Object) - */ - public IEditorInput getEditorInput( Object element ) { - if ( element instanceof IMarker ) { - IResource resource = ((IMarker)element).getResource(); - if ( resource instanceof IFile ) - return new FileEditorInput( (IFile)resource ); - } - if ( element instanceof IFile ) { - return new FileEditorInput( (IFile)element ); - } - if ( element instanceof ICLineBreakpoint ) { - IFile file = (IFile)((ICLineBreakpoint)element).getMarker().getResource().getAdapter( IFile.class ); - if ( file != null ) - return new FileEditorInput( file ); - } - if ( element instanceof FileStorage ) { - return new ExternalEditorInput( (IStorage)element ); - } - if ( element instanceof FileNotFoundElement ) { - return new EditorInputDelegate( (FileNotFoundElement)element ); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(IEditorInput, Object) - */ - public String getEditorId( IEditorInput input, Object element ) { - if ( input instanceof EditorInputDelegate ) { - if ( ((EditorInputDelegate)input).getDelegate() == null ) - return CDebugEditor.EDITOR_ID; - return getEditorId( ((EditorInputDelegate)input).getDelegate(), element ); - } - String id = null; - if ( input != null ) { - IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - IEditorDescriptor descriptor = registry.getDefaultEditor( input.getName() ); - id = (descriptor != null) ? descriptor.getId() : CUIPlugin.EDITOR_ID; - } - if ( CUIPlugin.EDITOR_ID.equals( id ) ) { - return CDebugEditor.EDITOR_ID; - } - return id; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.ui.ILabelProvider#getImage(Object) - */ - public Image getImage( Object element ) { - Image baseImage = getBaseImage( element ); - if ( baseImage != null ) { - ImageDescriptor[] overlays = new ImageDescriptor[]{ null, null, null, null }; - if ( element instanceof ICDebugElementStatus && !((ICDebugElementStatus)element).isOK() ) { - switch( ((ICDebugElementStatus)element).getSeverity() ) { - case ICDebugElementStatus.WARNING: - overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_WARNING; - break; - case ICDebugElementStatus.ERROR: - overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_ERROR; - break; - } - } - if ( element instanceof IWatchExpression && ((IWatchExpression)element).hasErrors() ) - overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_ERROR; - if ( element instanceof ICVariable && ((ICVariable)element).isArgument() ) - overlays[OverlayImageDescriptor.TOP_RIGHT] = CDebugImages.DESC_OVRS_ARGUMENT; - if ( element instanceof ICGlobalVariable && !(element instanceof IRegister) ) - overlays[OverlayImageDescriptor.TOP_RIGHT] = CDebugImages.DESC_OVRS_GLOBAL; - return fImageCache.getImageFor( new OverlayImageDescriptor( baseImage, overlays ) ); - } - return null; - } - - private Image getBaseImage( Object element ) { - if ( element instanceof ICDebugTarget ) { - ICDebugTarget target = (ICDebugTarget)element; - if ( target.isPostMortem() ) { - return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED ) ); - } - if ( target.isTerminated() || target.isDisconnected() ) { - return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED ) ); - } - return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_DEBUG_TARGET ) ); - } - if ( element instanceof ICThread ) { - ICThread thread = (ICThread)element; - ICDebugTarget target = (ICDebugTarget)thread.getDebugTarget(); - if ( target.isPostMortem() ) { - return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_TERMINATED ) ); - } - if ( thread.isSuspended() ) { - return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED ) ); - } - else if ( thread.isTerminated() ) { - return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_TERMINATED ) ); - } - else { - return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_RUNNING ) ); - } - } - try { - if ( element instanceof IMarker ) { - IBreakpoint bp = getBreakpoint( (IMarker)element ); - if ( bp != null && bp instanceof ICBreakpoint ) { - return getBreakpointImage( (ICBreakpoint)bp ); - } - } - if ( element instanceof ICBreakpoint ) { - return getBreakpointImage( (ICBreakpoint)element ); - } - if ( element instanceof IRegisterGroup ) { - return getRegisterGroupImage( (IRegisterGroup)element ); - } - if ( element instanceof IExpression ) { - return getExpressionImage( (IExpression)element ); - } - if ( element instanceof IRegister ) { - return getRegisterImage( (IRegister)element ); - } - if ( element instanceof IVariable ) { - return getVariableImage( (IVariable)element ); - } - if ( element instanceof ICSharedLibrary ) { - return getSharedLibraryImage( (ICSharedLibrary)element ); - } - } - catch( CoreException e ) { - } - return super.getImage( element ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.ui.ILabelProvider#getText(Object) - */ - public String getText( Object element ) { - StringBuffer baseText = new StringBuffer( getBaseText( element ) ); - if ( element instanceof ICDebugElementStatus && !((ICDebugElementStatus)element).isOK() ) { - baseText.append( getFormattedString( " <{0}>", ((ICDebugElementStatus)element).getMessage() ) ); //$NON-NLS-1$ - } - if ( element instanceof IAdaptable ) { - IEnableDisableTarget target = (IEnableDisableTarget)((IAdaptable)element).getAdapter( IEnableDisableTarget.class ); - if ( target != null ) { - if ( !target.isEnabled() ) { - baseText.append( ' ' ); - baseText.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.25" ) ); //$NON-NLS-1$ - } - } - } - return baseText.toString(); - } - - private String getBaseText( Object element ) { - boolean showQualified = isShowQualifiedNames(); - StringBuffer label = new StringBuffer(); - try { - if ( element instanceof ICSharedLibrary ) { - label.append( getSharedLibraryText( (ICSharedLibrary)element, showQualified ) ); - return label.toString(); - } - if ( element instanceof ICSignal ) { - label.append( getSignalText( (ICSignal)element ) ); - return label.toString(); - } - if ( element instanceof IRegisterGroup ) { - label.append( ((IRegisterGroup)element).getName() ); - return label.toString(); - } - if ( element instanceof IWatchExpression ) { - return getWatchExpressionText( (IWatchExpression)element ); - } - if ( element instanceof IVariable ) { - label.append( getVariableText( (IVariable)element ) ); - return label.toString(); - } - if ( element instanceof IValue ) { - label.append( getValueText( (IValue)element ) ); - return label.toString(); - } - if ( element instanceof IStackFrame ) { - label.append( getStackFrameText( (IStackFrame)element, showQualified ) ); - return label.toString(); - } - if ( element instanceof IMarker ) { - IBreakpoint breakpoint = getBreakpoint( (IMarker)element ); - if ( breakpoint != null ) { - return getBreakpointText( breakpoint, showQualified ); - } - return null; - } - if ( element instanceof IBreakpoint ) { - return getBreakpointText( (IBreakpoint)element, showQualified ); - } - if ( element instanceof IDebugTarget ) - label.append( getTargetText( (IDebugTarget)element, showQualified ) ); - else if ( element instanceof IThread ) - label.append( getThreadText( (IThread)element, showQualified ) ); - if ( element instanceof ITerminate ) { - if ( ((ITerminate)element).isTerminated() ) { - label.insert( 0, CDebugUIMessages.getString( "CDTDebugModelPresentation.0" ) ); //$NON-NLS-1$ - return label.toString(); - } - } - if ( element instanceof IDisconnect ) { - if ( ((IDisconnect)element).isDisconnected() ) { - label.insert( 0, CDebugUIMessages.getString( "CDTDebugModelPresentation.1" ) ); //$NON-NLS-1$ - return label.toString(); - } - } - if ( label.length() > 0 ) { - return label.toString(); - } - } - catch( DebugException e ) { - return MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.2" ), new String[] { e.getMessage() } ); //$NON-NLS-1$ - } - catch( CoreException e ) { - CDebugUIPlugin.log( e ); - } - return getDefaultText( element ); - } - - protected boolean isShowQualifiedNames() { - Boolean showQualified = (Boolean)fAttributes.get( DISPLAY_FULL_PATHS ); - showQualified = showQualified == null ? Boolean.FALSE : showQualified; - return showQualified.booleanValue(); - } - - protected boolean isShowVariableTypeNames() { - Boolean show = (Boolean)fAttributes.get( DISPLAY_VARIABLE_TYPE_NAMES ); - show = show == null ? Boolean.FALSE : show; - return show.booleanValue(); - } - - protected String getTargetText( IDebugTarget target, boolean qualified ) throws DebugException { - ICDebugTarget t = (ICDebugTarget)target.getAdapter( ICDebugTarget.class ); - if ( t != null ) { - if ( !t.isPostMortem() ) { - CDebugElementState state = t.getState(); - if ( state.equals( CDebugElementState.EXITED ) ) { - Object info = t.getCurrentStateInfo(); - String label = CDebugUIMessages.getString( "CDTDebugModelPresentation.3" ); //$NON-NLS-1$ - String reason = ""; //$NON-NLS-1$ - if ( info != null && info instanceof ICDISignalExitInfo ) { - ICDISignalExitInfo sigInfo = (ICDISignalExitInfo)info; - reason = ' ' + MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.5" ), new String[]{ sigInfo.getName(), sigInfo.getDescription() } ); //$NON-NLS-1$ - } - else if ( info != null && info instanceof ICDIExitInfo ) { - reason = ' ' + MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.6" ), new Integer[] { new Integer( ((ICDIExitInfo)info).getCode() ) } ); //$NON-NLS-1$ - } - return MessageFormat.format( label, new String[] { target.getName(), reason } ); - } - else if ( state.equals( CDebugElementState.SUSPENDED ) ) { - return MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.7" ), new String[] { target.getName() } ); //$NON-NLS-1$ - } - } - } - return target.getName(); - } - - protected String getThreadText( IThread thread, boolean qualified ) throws DebugException { - ICDebugTarget target = (ICDebugTarget)thread.getDebugTarget().getAdapter( ICDebugTarget.class ); - if ( target.isPostMortem() ) { - return getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.8" ), thread.getName() ); //$NON-NLS-1$ - } - if ( thread.isTerminated() ) { - return getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.9" ), thread.getName() ); //$NON-NLS-1$ - } - if ( thread.isStepping() ) { - return getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.10" ), thread.getName() ); //$NON-NLS-1$ - } - if ( !thread.isSuspended() ) { - return getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.11" ), thread.getName() ); //$NON-NLS-1$ - } - if ( thread.isSuspended() ) { - String reason = ""; //$NON-NLS-1$ - ICDebugElement element = (ICDebugElement)thread.getAdapter( ICDebugElement.class ); - if ( element != null ) { - Object info = element.getCurrentStateInfo(); - if ( info != null && info instanceof ICDISignalReceived ) { - ICDISignal signal = ((ICDISignalReceived)info).getSignal(); - reason = MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.13" ), new String[]{ signal.getName(), signal.getDescription() } ); //$NON-NLS-1$ - } - else if ( info != null && info instanceof ICDIWatchpointTrigger ) { - reason = MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.14" ), new String[]{ ((ICDIWatchpointTrigger)info).getOldValue(), ((ICDIWatchpointTrigger)info).getNewValue() } ); //$NON-NLS-1$ - } - else if ( info != null && info instanceof ICDIWatchpointScope ) { - reason = CDebugUIMessages.getString( "CDTDebugModelPresentation.15" ); //$NON-NLS-1$ - } - else if ( info != null && info instanceof ICDIBreakpointHit ) { - reason = CDebugUIMessages.getString( "CDTDebugModelPresentation.16" ); //$NON-NLS-1$ - } - else if ( info != null && info instanceof ICDISharedLibraryEvent ) { - reason = CDebugUIMessages.getString( "CDTDebugModelPresentation.17" ); //$NON-NLS-1$ - } - } - return MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.18" ), new String[] { thread.getName(), reason } ); //$NON-NLS-1$ - } - return MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.19" ), new String[] { thread.getName() } ); //$NON-NLS-1$ - } - - protected String getStackFrameText( IStackFrame f, boolean qualified ) throws DebugException { - if ( f instanceof ICStackFrame ) { - ICStackFrame frame = (ICStackFrame)f; - StringBuffer label = new StringBuffer(); - label.append( frame.getLevel() ); - label.append( ' ' ); - String function = frame.getFunction(); - if ( function != null ) { - function = function.trim(); - if ( function.length() > 0 ) { - label.append( function ); - label.append( "() " ); //$NON-NLS-1$ - if ( frame.getFile() != null ) { - IPath path = new Path( frame.getFile() ); - if ( !path.isEmpty() ) { - label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.20" ) ); //$NON-NLS-1$ - label.append( ' ' ); - label.append( (qualified ? path.toOSString() : path.lastSegment()) ); - label.append( ':' ); - if ( frame.getFrameLineNumber() != 0 ) - label.append( frame.getFrameLineNumber() ); - } - } - } - } - if ( isEmpty( function ) ) - label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.21" ) ); //$NON-NLS-1$ - return label.toString(); - } - return (f.getAdapter( IDummyStackFrame.class ) != null) ? getDummyStackFrameLabel( f ) : f.getName(); - } - - private String getDummyStackFrameLabel( IStackFrame stackFrame ) { - return DUMMY_STACKFRAME_LABEL; - } - - protected String getWatchExpressionText( IWatchExpression expression ) { - StringBuffer result = new StringBuffer(); - result.append( '"' ).append( expression.getExpressionText() ).append( '"' ); - if ( expression.isPending() ) { - result.append( " = " ).append( "..." ); //$NON-NLS-1$//$NON-NLS-2$ - } - else { - IValue value = expression.getValue(); - if ( value instanceof ICValue ) { - ICType type = null; - try { - type = ((ICValue)value).getType(); - } - catch( DebugException e1 ) { - } - if ( type != null && isShowVariableTypeNames() ) { - String typeName = getVariableTypeName( type ); - if ( !isEmpty( typeName ) ) { - result.insert( 0, typeName + ' ' ); - } - } - if ( expression.isEnabled() ) { - String valueString = getValueText( value ); - if ( valueString.length() > 0 ) { - result.append( " = " ).append( valueString ); //$NON-NLS-1$ - } - } - } - } - if ( !expression.isEnabled() ) { - result.append( ' ' ); - result.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.22" ) ); //$NON-NLS-1$ - } - return result.toString(); - } - - protected String getVariableText( IVariable var ) throws DebugException { - StringBuffer label = new StringBuffer(); - if ( var instanceof ICVariable ) { - ICType type = null; - try { - type = ((ICVariable)var).getType(); - } - catch( DebugException e ) { - // don't display type - } - if ( type != null && isShowVariableTypeNames() ) { - String typeName = getVariableTypeName( type ); - if ( typeName != null && typeName.length() > 0 ) { - label.append( typeName ).append( ' ' ); - } - } - String name = var.getName(); - if ( name != null ) - label.append( name.trim() ); - IValue value = var.getValue(); - if ( value != null ) { - String valueString = getValueText( value ); - if ( !isEmpty( valueString ) ) { - label.append( " = " ); //$NON-NLS-1$ - label.append( valueString ); - } - } - } - return label.toString(); - } - - protected String getValueText( IValue value )/* throws DebugException*/ { - StringBuffer label = new StringBuffer(); - if ( value instanceof ICDebugElementStatus && !((ICDebugElementStatus)value).isOK() ) { - label.append( getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.4" ), ((ICDebugElementStatus)value).getMessage() ) ); //$NON-NLS-1$ - } - else if ( value instanceof ICValue ) { - ICType type = null; - try { - type = ((ICValue)value).getType(); - } - catch( DebugException e ) { - } - try { - String valueString = value.getValueString(); - if ( valueString != null ) { - valueString = valueString.trim(); - if ( type != null && type.isCharacter() ) { - if ( valueString.length() == 0 ) - valueString = "."; //$NON-NLS-1$ - label.append( valueString ); - } - else if ( type != null && type.isFloatingPointType() ) { - Number floatingPointValue = CDebugUtils.getFloatingPointValue( (ICValue)value ); - if ( CDebugUtils.isNaN( floatingPointValue ) ) - valueString = "NAN"; //$NON-NLS-1$ - if ( CDebugUtils.isPositiveInfinity( floatingPointValue ) ) - valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.23" ); //$NON-NLS-1$ - if ( CDebugUtils.isNegativeInfinity( floatingPointValue ) ) - valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.24" ); //$NON-NLS-1$ - label.append( valueString ); - } - else if ( type == null || (!type.isArray() && !type.isStructure()) ) { - if ( valueString.length() > 0 ) { - label.append( valueString ); - } - } - } - } - catch( DebugException e1 ) { - } - } - return label.toString(); - } - - protected String getSharedLibraryText( ICSharedLibrary library, boolean qualified ) { - String label = new String(); - IPath path = new Path( library.getFileName() ); - if ( !path.isEmpty() ) - label += (qualified ? path.toOSString() : path.lastSegment()); - return label; - } - - protected String getSignalText( ICSignal signal ) { - StringBuffer sb = new StringBuffer( CDebugUIMessages.getString( "CDTDebugModelPresentation.12" ) ); //$NON-NLS-1$ - try { - String name = signal.getName(); - sb.append( " \'" ).append( name ).append( '\'' ); //$NON-NLS-1$ - } - catch( DebugException e ) { - } - return sb.toString(); - } - - /** - * Plug in the single argument to the resource String for the key to get a formatted resource String. - * - */ - public static String getFormattedString( String key, String arg ) { - return getFormattedString( key, new String[]{ arg } ); - } - - /** - * Plug in the arguments to the resource String for the key to get a formatted resource String. - * - */ - public static String getFormattedString( String string, String[] args ) { - return MessageFormat.format( string, args ); - } - - protected Image getBreakpointImage( ICBreakpoint breakpoint ) throws CoreException { - if ( breakpoint instanceof ICLineBreakpoint ) { - return getLineBreakpointImage( (ICLineBreakpoint)breakpoint ); - } - if ( breakpoint instanceof ICWatchpoint ) { - return getWatchpointImage( (ICWatchpoint)breakpoint ); - } - return null; - } - - protected Image getLineBreakpointImage( ICLineBreakpoint breakpoint ) throws CoreException { - ImageDescriptor descriptor = null; - if ( breakpoint.isEnabled() ) { - descriptor = CDebugImages.DESC_OBJS_BREAKPOINT_ENABLED; - } - else { - descriptor = CDebugImages.DESC_OBJS_BREAKPOINT_DISABLED; - } - return fImageCache.getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeBreakpointOverlays( breakpoint ) ) ); - } - - protected Image getWatchpointImage( ICWatchpoint watchpoint ) throws CoreException { - ImageDescriptor descriptor = null; - if ( watchpoint.isEnabled() ) { - if ( watchpoint.isReadType() && !watchpoint.isWriteType() ) - descriptor = CDebugImages.DESC_OBJS_READ_WATCHPOINT_ENABLED; - else if ( !watchpoint.isReadType() && watchpoint.isWriteType() ) - descriptor = CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_ENABLED; - else - descriptor = CDebugImages.DESC_OBJS_WATCHPOINT_ENABLED; - } - else { - if ( watchpoint.isReadType() && !watchpoint.isWriteType() ) - descriptor = CDebugImages.DESC_OBJS_READ_WATCHPOINT_DISABLED; - else if ( !watchpoint.isReadType() && watchpoint.isWriteType() ) - descriptor = CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_DISABLED; - else - descriptor = CDebugImages.DESC_OBJS_WATCHPOINT_DISABLED; - } - return fImageCache.getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeBreakpointOverlays( watchpoint ) ) ); - } - - protected IBreakpoint getBreakpoint( IMarker marker ) { - return DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker ); - } - - protected String getBreakpointText( IBreakpoint breakpoint, boolean qualified ) throws CoreException { - if ( breakpoint instanceof ICAddressBreakpoint ) { - return getAddressBreakpointText( (ICAddressBreakpoint)breakpoint, qualified ); - } - if ( breakpoint instanceof ICFunctionBreakpoint ) { - return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified ); - } - if ( breakpoint instanceof ICLineBreakpoint ) { - return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified ); - } - if ( breakpoint instanceof ICWatchpoint ) { - return getWatchpointText( (ICWatchpoint)breakpoint, qualified ); - } - return ""; //$NON-NLS-1$ - } - - protected String getLineBreakpointText( ICLineBreakpoint breakpoint, boolean qualified ) throws CoreException { - StringBuffer label = new StringBuffer(); - appendSourceName( breakpoint, label, qualified ); - appendLineNumber( breakpoint, label ); - appendIgnoreCount( breakpoint, label ); - appendCondition( breakpoint, label ); - return label.toString(); - } - - protected String getWatchpointText( ICWatchpoint watchpoint, boolean qualified ) throws CoreException { - StringBuffer label = new StringBuffer(); - appendSourceName( watchpoint, label, qualified ); - appendWatchExpression( watchpoint, label ); - appendIgnoreCount( watchpoint, label ); - appendCondition( watchpoint, label ); - return label.toString(); - } - - protected String getAddressBreakpointText( ICAddressBreakpoint breakpoint, boolean qualified ) throws CoreException { - StringBuffer label = new StringBuffer(); - appendSourceName( breakpoint, label, qualified ); - appendAddress( breakpoint, label ); - appendIgnoreCount( breakpoint, label ); - appendCondition( breakpoint, label ); - return label.toString(); - } - - protected String getFunctionBreakpointText( ICFunctionBreakpoint breakpoint, boolean qualified ) throws CoreException { - StringBuffer label = new StringBuffer(); - appendSourceName( breakpoint, label, qualified ); - appendFunction( breakpoint, label ); - appendIgnoreCount( breakpoint, label ); - appendCondition( breakpoint, label ); - return label.toString(); - } - - protected StringBuffer appendSourceName( ICBreakpoint breakpoint, StringBuffer label, boolean qualified ) throws CoreException { - String handle = breakpoint.getSourceHandle(); - if ( !isEmpty( handle ) ) { - IPath path = new Path( handle ); - if ( path.isValidPath( handle ) ) { - label.append( qualified ? path.toOSString() : path.lastSegment() ); - } - } - return label; - } - - protected StringBuffer appendLineNumber( ICLineBreakpoint breakpoint, StringBuffer label ) throws CoreException { - int lineNumber = breakpoint.getLineNumber(); - if ( lineNumber > 0 ) { - label.append( ' ' ); - label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.26" ), new String[]{ Integer.toString( lineNumber ) } ) ); //$NON-NLS-1$ - } - return label; - } - - protected StringBuffer appendAddress( ICAddressBreakpoint breakpoint, StringBuffer label ) throws CoreException { - try { - label.append( ' ' ); - label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.27" ), new String[]{ breakpoint.getAddress() } ) ); //$NON-NLS-1$ - } - catch( NumberFormatException e ) { - } - return label; - } - - protected StringBuffer appendFunction( ICFunctionBreakpoint breakpoint, StringBuffer label ) throws CoreException { - String function = breakpoint.getFunction(); - if ( function != null && function.trim().length() > 0 ) { - label.append( ' ' ); - label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.28" ), new String[]{ function.trim() } ) ); //$NON-NLS-1$ - } - return label; - } - - protected StringBuffer appendIgnoreCount( ICBreakpoint breakpoint, StringBuffer label ) throws CoreException { - int ignoreCount = breakpoint.getIgnoreCount(); - if ( ignoreCount > 0 ) { - label.append( ' ' ); - label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.29" ), new String[]{ Integer.toString( ignoreCount ) } ) ); //$NON-NLS-1$ - } - return label; - } - - protected void appendCondition( ICBreakpoint breakpoint, StringBuffer buffer ) throws CoreException { - String condition = breakpoint.getCondition(); - if ( condition != null && condition.length() > 0 ) { - buffer.append( ' ' ); - buffer.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.30" ) ); //$NON-NLS-1$ - buffer.append( ' ' ); - buffer.append( condition ); - } - } - - private void appendWatchExpression( ICWatchpoint watchpoint, StringBuffer label ) throws CoreException { - String expression = watchpoint.getExpression(); - if ( expression != null && expression.length() > 0 ) { - label.append( ' ' ); - label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.31" ) ); //$NON-NLS-1$ - label.append( " \'" ); //$NON-NLS-1$ - label.append( expression ); - label.append( '\'' ); - } - } - - private ImageDescriptor[] computeBreakpointOverlays( ICBreakpoint breakpoint ) { - ImageDescriptor[] overlays = new ImageDescriptor[]{ null, null, null, null }; - try { - if ( breakpoint.isConditional() ) { - overlays[OverlayImageDescriptor.TOP_LEFT] = (breakpoint.isEnabled()) ? CDebugImages.DESC_OVRS_BREAKPOINT_CONDITIONAL : CDebugImages.DESC_OVRS_BREAKPOINT_CONDITIONAL_DISABLED; - } - if ( breakpoint.isInstalled() ) { - overlays[OverlayImageDescriptor.BOTTOM_LEFT] = (breakpoint.isEnabled()) ? CDebugImages.DESC_OVRS_BREAKPOINT_INSTALLED : CDebugImages.DESC_OVRS_BREAKPOINT_INSTALLED_DISABLED; - } - if ( breakpoint instanceof ICAddressBreakpoint ) { - overlays[OverlayImageDescriptor.TOP_RIGHT] = (breakpoint.isEnabled()) ? CDebugImages.DESC_OVRS_ADDRESS_BREAKPOINT : CDebugImages.DESC_OVRS_ADDRESS_BREAKPOINT_DISABLED; - } - if ( breakpoint instanceof ICFunctionBreakpoint ) { - overlays[OverlayImageDescriptor.TOP_RIGHT] = (breakpoint.isEnabled()) ? CDebugImages.DESC_OVRS_FUNCTION_BREAKPOINT : CDebugImages.DESC_OVRS_FUNCTION_BREAKPOINT_DISABLED; - } - } - catch( CoreException e ) { - CDebugUIPlugin.log( e ); - } - return overlays; - } - - protected Image getVariableImage( IVariable element ) { - if ( element instanceof ICVariable ) { - ICType type = null; - try { - type = ((ICVariable)element).getType(); - } - catch( DebugException e ) { - // use default image - } - if ( type != null && (type.isPointer() || type.isReference()) ) - return fDebugImageRegistry.get( (((ICVariable)element).isEnabled()) ? CDebugImages.DESC_OBJS_VARIABLE_POINTER : CDebugImages.DESC_OBJS_VARIABLE_POINTER_DISABLED ); - else if ( type != null && (type.isArray() || type.isStructure()) ) - return fDebugImageRegistry.get( (((ICVariable)element).isEnabled()) ? CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE : CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE_DISABLED ); - else - return fDebugImageRegistry.get( (((ICVariable)element).isEnabled()) ? CDebugImages.DESC_OBJS_VARIABLE_SIMPLE : CDebugImages.DESC_OBJS_VARIABLE_SIMPLE_DISABLED ); - } - return null; - } - - protected Image getRegisterGroupImage( IRegisterGroup element ) { - IEnableDisableTarget target = (IEnableDisableTarget)element.getAdapter( IEnableDisableTarget.class ); - if ( target != null && !target.isEnabled() ) - return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_GROUP_DISABLED ); - return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_GROUP ); - } - - protected Image getRegisterImage( IRegister element ) { - return ( ( element instanceof ICVariable && ((ICVariable)element).isEnabled() ) ) ? fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER ) : fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_DISABLED ); - } - - protected Image getExpressionImage( IExpression element ) { - return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_EXPRESSION ) ); - } - - protected Image getSharedLibraryImage( ICSharedLibrary element ) { - if ( element.areSymbolsLoaded() ) { - return fImageCache.getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( CDebugImages.DESC_OBJS_LOADED_SHARED_LIBRARY ), new ImageDescriptor[]{ null, CDebugImages.DESC_OVRS_SYMBOLS, null, null } ) ); - } - return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_SHARED_LIBRARY ); - } - - private String getVariableTypeName( ICType type ) { - StringBuffer result = new StringBuffer(); - String typeName = type.getName(); - if ( typeName != null ) - typeName = typeName.trim(); - if ( type.isArray() && typeName != null ) { - int index = typeName.indexOf( '[' ); - if ( index != -1 ) - typeName = typeName.substring( 0, index ).trim(); - } - if ( typeName != null && typeName.length() > 0 ) { - result.append( typeName ); - if ( type.isArray() ) { - int[] dims = type.getArrayDimensions(); - for( int i = 0; i < dims.length; ++i ) { - result.append( '[' ); - result.append( dims[i] ); - result.append( ']' ); - } - } - } - return result.toString(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - fImageCache.disposeAll(); - } - - private boolean isEmpty( String str ) { - return (str == null || str.length() == 0); - } - - /** - * Returns a default text label for the debug element - */ - protected String getDefaultText( Object element ) { - return DebugUIPlugin.getDefaultLabelProvider().getText( element ); - } - - /** - * Returns a default image for the debug element - */ - protected Image getDefaultImage( Object element ) { - return DebugUIPlugin.getDefaultLabelProvider().getImage( element ); - } -} 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 01fc51c3f8e..3098a7c265f 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 @@ -95,7 +95,9 @@ public class CDebugImages public static final String IMG_OBJS_PROJECT = NAME_PREFIX + "project_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_CLOSED_PROJECT = NAME_PREFIX + "cproject_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 + "library_syms_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_EXECUTABLE_WITH_SYMBOLS = NAME_PREFIX + "exec_dbg_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_EXECUTABLE = NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_SHARED_LIBRARY_WITH_SYMBOLS = 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_OBJS_SIGNAL = NAME_PREFIX + "signal_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_WORKSPACE_SOURCE_FILE = NAME_PREFIX + "prj_file_obj.gif"; //$NON-NLS-1$ @@ -112,6 +114,10 @@ public class CDebugImages public static final String IMG_LCL_CAST_TO_TYPE = NAME_PREFIX + "casttotype_co.gif"; //$NON-NLS-1$ public static final String IMG_LCL_DISPLAY_AS_ARRAY = NAME_PREFIX + "showasarray_co.gif"; //$NON-NLS-1$ public static final String IMG_LCL_RESUME_AT_LINE = NAME_PREFIX + "jump_co.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_DETAIL_PANE_UNDER = NAME_PREFIX + "det_pane_under.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_DETAIL_PANE_RIGHT = NAME_PREFIX + "det_pane_right.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_DETAIL_PANE_HIDE = NAME_PREFIX + "det_pane_hide.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_COLLAPSE_ALL = NAME_PREFIX + "collapseall.gif"; //$NON-NLS-1$ public static final String IMG_TOOLS_ADD_DIR_SOURCE_LOCATION = NAME_PREFIX + "adddirsource_wiz.gif"; //$NON-NLS-1$ public static final String IMG_TOOLS_ADD_PRJ_SOURCE_LOCATION = NAME_PREFIX + "addprjsource_wiz.gif"; //$NON-NLS-1$ @@ -128,6 +134,7 @@ public class CDebugImages private static final String T_WIZBAN = "wizban"; //$NON-NLS-1$ private static final String T_LCL = "lcl16"; //$NON-NLS-1$ private static final String T_CLCL = "clcl16"; //$NON-NLS-1$ + private static final String T_ELCL = "elcl16"; //$NON-NLS-1$ private static final String T_DLCL = "dlcl16"; //$NON-NLS-1$ private static final String T_CTOOL = "ctool16"; //$NON-NLS-1$ // private static final String T_CVIEW = "cview16"; //$NON-NLS-1$ @@ -171,7 +178,9 @@ public class CDebugImages public static final ImageDescriptor DESC_OBJS_PROJECT = createManaged( T_OBJ, IMG_OBJS_PROJECT ); public static final ImageDescriptor DESC_OBJS_CLOSED_PROJECT = createManaged( T_OBJ, IMG_OBJS_CLOSED_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_EXECUTABLE_WITH_SYMBOLS = createManaged( T_OBJ, IMG_OBJS_EXECUTABLE_WITH_SYMBOLS ); + public static final ImageDescriptor DESC_OBJS_EXECUTABLE = createManaged( T_OBJ, IMG_OBJS_EXECUTABLE ); + public static final ImageDescriptor DESC_OBJS_SHARED_LIBRARY_WITH_SYMBOLS = createManaged( T_OBJ, IMG_OBJS_SHARED_LIBRARY_WITH_SYMBOLS ); public static final ImageDescriptor DESC_OBJS_SHARED_LIBRARY = createManaged( T_OBJ, IMG_OBJS_SHARED_LIBRARY ); public static final ImageDescriptor DESC_OBJS_SIGNAL = createManaged( T_OBJ, IMG_OBJS_SIGNAL ); public static final ImageDescriptor DESC_OBJS_WORKSPACE_SOURCE_FILE = createManaged( T_OBJ, IMG_OBJS_WORKSPACE_SOURCE_FILE ); @@ -185,6 +194,14 @@ public class CDebugImages public static final ImageDescriptor DESC_LCL_DISPLAY_AS_ARRAY = createManaged( T_CLCL, IMG_LCL_DISPLAY_AS_ARRAY ); public static final ImageDescriptor DESC_LCL_RESUME_AT_LINE = createManaged( T_CLCL, IMG_LCL_RESUME_AT_LINE ); public static final ImageDescriptor DESC_LCL_RESUME_AT_LINE_DISABLED = createManaged( T_DLCL, IMG_LCL_RESUME_AT_LINE ); + public static final ImageDescriptor DESC_LCL_DETAIL_PANE_UNDER = createManaged( T_ELCL, IMG_LCL_DETAIL_PANE_UNDER ); + public static final ImageDescriptor DESC_LCL_DETAIL_PANE_UNDER_DISABLED = createManaged( T_DLCL, IMG_LCL_DETAIL_PANE_UNDER ); + public static final ImageDescriptor DESC_LCL_DETAIL_PANE_RIGHT = createManaged( T_ELCL, IMG_LCL_DETAIL_PANE_RIGHT ); + public static final ImageDescriptor DESC_LCL_DETAIL_PANE_RIGHT_DISABLED = createManaged( T_DLCL, IMG_LCL_DETAIL_PANE_RIGHT ); + public static final ImageDescriptor DESC_LCL_DETAIL_PANE_HIDE = createManaged( T_ELCL, IMG_LCL_DETAIL_PANE_HIDE ); + public static final ImageDescriptor DESC_LCL_DETAIL_PANE_HIDE_DISABLED = createManaged( T_DLCL, IMG_LCL_DETAIL_PANE_HIDE ); + public static final ImageDescriptor DESC_LCL_COLLAPSE_ALL = createManaged( T_ELCL, IMG_LCL_COLLAPSE_ALL ); + public static final ImageDescriptor DESC_LCL_COLLAPSE_ALL_DISABLED = createManaged( T_DLCL, IMG_LCL_COLLAPSE_ALL ); /** * Returns the image managed under the given key in this registry. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java index 7c986af98ee..1388085de22 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java @@ -10,29 +10,80 @@ ***********************************************************************/ 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; +import org.eclipse.cdt.debug.core.cdi.ICDIExitInfo; +import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryEvent; +import org.eclipse.cdt.debug.core.cdi.ICDISignalExitInfo; +import org.eclipse.cdt.debug.core.cdi.ICDISignalReceived; +import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointScope; +import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger; +import org.eclipse.cdt.debug.core.cdi.model.ICDISignal; +import org.eclipse.cdt.debug.core.model.CDebugElementState; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.core.model.ICDebugElement; +import org.eclipse.cdt.debug.core.model.ICDebugElementStatus; +import org.eclipse.cdt.debug.core.model.ICDebugTarget; 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; +import org.eclipse.cdt.debug.core.model.ICType; +import org.eclipse.cdt.debug.core.model.ICValue; +import org.eclipse.cdt.debug.core.model.ICVariable; import org.eclipse.cdt.debug.core.model.ICWatchpoint; +import org.eclipse.cdt.debug.core.model.IDummyStackFrame; +import org.eclipse.cdt.debug.core.model.IEnableDisableTarget; +import org.eclipse.cdt.debug.internal.ui.editors.CDebugEditor; +import org.eclipse.cdt.debug.internal.ui.editors.EditorInputDelegate; +import org.eclipse.cdt.debug.internal.ui.editors.FileNotFoundElement; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.cdt.internal.ui.util.ExternalEditorInput; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IStorage; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.core.model.IDisconnect; +import org.eclipse.debug.core.model.IExpression; +import org.eclipse.debug.core.model.IRegister; import org.eclipse.debug.core.model.IRegisterGroup; +import org.eclipse.debug.core.model.IStackFrame; +import org.eclipse.debug.core.model.ITerminate; +import org.eclipse.debug.core.model.IThread; import org.eclipse.debug.core.model.IValue; +import org.eclipse.debug.core.model.IVariable; +import org.eclipse.debug.core.model.IWatchExpression; import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugModelPresentation; +import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IValueDetailListener; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorRegistry; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.FileEditorInput; /** * @see IDebugModelPresentation @@ -41,6 +92,8 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode public final static String DISPLAY_FULL_PATHS = "DISPLAY_FULL_PATHS"; //$NON-NLS-1$ + private static final String DUMMY_STACKFRAME_LABEL = "..."; //$NON-NLS-1$ + protected HashMap fAttributes = new HashMap( 3 ); protected CDebugImageDescriptorRegistry fDebugImageRegistry = CDebugUIPlugin.getImageDescriptorRegistry(); @@ -68,15 +121,32 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode * @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 ) { - // TODO Auto-generated method stub - + CValueDetailProvider.getDefault().computeDetail( value, listener ); } /* (non-Javadoc) * @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(java.lang.Object) */ public IEditorInput getEditorInput( Object element ) { - // TODO Auto-generated method stub + if ( element instanceof IMarker ) { + IResource resource = ((IMarker)element).getResource(); + if ( resource instanceof IFile ) + return new FileEditorInput( (IFile)resource ); + } + if ( element instanceof IFile ) { + return new FileEditorInput( (IFile)element ); + } + if ( element instanceof ICLineBreakpoint ) { + IFile file = (IFile)((ICLineBreakpoint)element).getMarker().getResource().getAdapter( IFile.class ); + if ( file != null ) + return new FileEditorInput( file ); + } + if ( element instanceof FileStorage ) { + return new ExternalEditorInput( (IStorage)element ); + } + if ( element instanceof FileNotFoundElement ) { + return new EditorInputDelegate( (FileNotFoundElement)element ); + } return null; } @@ -84,39 +154,106 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode * @see org.eclipse.debug.ui.ISourcePresentation#getEditorId(org.eclipse.ui.IEditorInput, java.lang.Object) */ public String getEditorId( IEditorInput input, Object element ) { - // TODO Auto-generated method stub - return null; + if ( input instanceof EditorInputDelegate ) { + if ( ((EditorInputDelegate)input).getDelegate() == null ) + return CDebugEditor.EDITOR_ID; + return getEditorId( ((EditorInputDelegate)input).getDelegate(), element ); + } + String id = null; + if ( input != null ) { + IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); + IEditorDescriptor descriptor = registry.getDefaultEditor( input.getName() ); + id = (descriptor != null) ? descriptor.getId() : CUIPlugin.EDITOR_ID; + } + if ( CUIPlugin.EDITOR_ID.equals( id ) ) { + return CDebugEditor.EDITOR_ID; + } + return id; } public Image getImage( Object element ) { Image baseImage = getBaseImage( element ); if ( baseImage != null ) { - ImageDescriptor[] overlays = new ImageDescriptor[] { null, null, null, null }; - + ImageDescriptor[] overlays = new ImageDescriptor[]{ null, null, null, null }; + if ( element instanceof ICDebugElementStatus && !((ICDebugElementStatus)element).isOK() ) { + switch( ((ICDebugElementStatus)element).getSeverity() ) { + case ICDebugElementStatus.WARNING: + overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_WARNING; + break; + case ICDebugElementStatus.ERROR: + overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_ERROR; + break; + } + } + if ( element instanceof IWatchExpression && ((IWatchExpression)element).hasErrors() ) + overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_ERROR; + if ( element instanceof ICVariable && ((ICVariable)element).isArgument() ) + overlays[OverlayImageDescriptor.TOP_RIGHT] = CDebugImages.DESC_OVRS_ARGUMENT; + if ( element instanceof ICGlobalVariable && !(element instanceof IRegister) ) + overlays[OverlayImageDescriptor.TOP_RIGHT] = CDebugImages.DESC_OVRS_GLOBAL; return getImageCache().getImageFor( new OverlayImageDescriptor( baseImage, overlays ) ); } return getDefaultImage( element ); } private Image getBaseImage( Object element ) { - if ( element instanceof ICSharedLibrary ) - return getSharedLibraryImage( (ICSharedLibrary)element ); - if ( element instanceof IRegisterGroup ) - return getRegisterGroupImage( (IRegisterGroup)element ); - if ( element instanceof ICSignal ) - return getSignalImage( (ICSignal)element ); - if ( element instanceof ICBreakpoint ) - return getBreakpointImage( (ICBreakpoint)element ); - return super.getImage( element ); - } - - protected Image getSharedLibraryImage( ICSharedLibrary element ) { - if ( element.areSymbolsLoaded() ) { - return getImageCache().getImageFor( - new OverlayImageDescriptor( getDebugImageRegistry().get( CDebugImages.DESC_OBJS_LOADED_SHARED_LIBRARY ), - new ImageDescriptor[] { null, CDebugImages.DESC_OVRS_SYMBOLS, null, null } ) ); + if ( element instanceof ICDebugTarget ) { + ICDebugTarget target = (ICDebugTarget)element; + if ( target.isPostMortem() ) { + return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED ) ); + } + if ( target.isTerminated() || target.isDisconnected() ) { + return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED ) ); + } + return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_DEBUG_TARGET ) ); } - return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_SHARED_LIBRARY ); + if ( element instanceof ICThread ) { + ICThread thread = (ICThread)element; + ICDebugTarget target = (ICDebugTarget)thread.getDebugTarget(); + if ( target.isPostMortem() ) { + return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_TERMINATED ) ); + } + if ( thread.isSuspended() ) { + return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED ) ); + } + else if ( thread.isTerminated() ) { + return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_TERMINATED ) ); + } + else { + return fDebugImageRegistry.get( DebugUITools.getImageDescriptor( IDebugUIConstants.IMG_OBJS_THREAD_RUNNING ) ); + } + } + if ( element instanceof IMarker ) { + IBreakpoint bp = getBreakpoint( (IMarker)element ); + if ( bp != null && bp instanceof ICBreakpoint ) { + return getBreakpointImage( (ICBreakpoint)bp ); + } + } + if ( element instanceof ICBreakpoint ) { + return getBreakpointImage( (ICBreakpoint)element ); + } + if ( element instanceof IRegisterGroup ) { + return getRegisterGroupImage( (IRegisterGroup)element ); + } + if ( element instanceof IExpression ) { + return getExpressionImage( (IExpression)element ); + } + if ( element instanceof IRegister ) { + return getRegisterImage( (IRegister)element ); + } + if ( element instanceof IVariable ) { + return getVariableImage( (IVariable)element ); + } + if ( element instanceof ICSharedLibrary ) { + return getSharedLibraryImage( (ICSharedLibrary)element ); + } + if ( element instanceof ICModule ) { + return getModuleImage( (ICModule)element ); + } + if ( element instanceof ICSignal ) { + return getSignalImage( (ICSignal)element ); + } + return super.getImage( element ); } protected Image getSignalImage( ICSignal signal ) { @@ -124,6 +261,9 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode } protected Image getRegisterGroupImage( IRegisterGroup element ) { + IEnableDisableTarget target = (IEnableDisableTarget)element.getAdapter( IEnableDisableTarget.class ); + if ( target != null && !target.isEnabled() ) + return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_GROUP_DISABLED ); return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_GROUP ); } @@ -170,31 +310,97 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode else descriptor = CDebugImages.DESC_OBJS_WATCHPOINT_DISABLED; } - return fImageCache.getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeBreakpointOverlays( watchpoint ) ) ); + return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeBreakpointOverlays( watchpoint ) ) ); } public String getText( Object element ) { StringBuffer baseText = new StringBuffer( getBaseText( element ) ); + if ( element instanceof ICDebugElementStatus && !((ICDebugElementStatus)element).isOK() ) { + baseText.append( getFormattedString( " <{0}>", ((ICDebugElementStatus)element).getMessage() ) ); //$NON-NLS-1$ + } + if ( element instanceof IAdaptable ) { + IEnableDisableTarget target = (IEnableDisableTarget)((IAdaptable)element).getAdapter( IEnableDisableTarget.class ); + if ( target != null ) { + if ( !target.isEnabled() ) { + baseText.append( ' ' ); + baseText.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.25" ) ); //$NON-NLS-1$ + } + } + } return baseText.toString(); } private String getBaseText( Object element ) { boolean showQualified = isShowQualifiedNames(); StringBuffer label = new StringBuffer(); - - if ( element instanceof ICSharedLibrary ) { - label.append( getSharedLibraryText( (ICSharedLibrary)element, showQualified ) ); - return label.toString(); + 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(); + } + if ( element instanceof ICSignal ) { + label.append( getSignalText( (ICSignal)element ) ); + return label.toString(); + } + if ( element instanceof IRegisterGroup ) { + label.append( ((IRegisterGroup)element).getName() ); + return label.toString(); + } + if ( element instanceof IWatchExpression ) { + return getWatchExpressionText( (IWatchExpression)element ); + } + if ( element instanceof IVariable ) { + label.append( getVariableText( (IVariable)element ) ); + return label.toString(); + } + if ( element instanceof IValue ) { + label.append( getValueText( (IValue)element ) ); + return label.toString(); + } + if ( element instanceof IStackFrame ) { + label.append( getStackFrameText( (IStackFrame)element, showQualified ) ); + return label.toString(); + } + if ( element instanceof IMarker ) { + IBreakpoint breakpoint = getBreakpoint( (IMarker)element ); + if ( breakpoint != null ) { + return getBreakpointText( breakpoint, showQualified ); + } + return null; + } + if ( element instanceof IBreakpoint ) { + return getBreakpointText( (IBreakpoint)element, showQualified ); + } + if ( element instanceof IDebugTarget ) + label.append( getTargetText( (IDebugTarget)element, showQualified ) ); + else if ( element instanceof IThread ) + label.append( getThreadText( (IThread)element, showQualified ) ); + if ( element instanceof ITerminate ) { + if ( ((ITerminate)element).isTerminated() ) { + label.insert( 0, CDebugUIMessages.getString( "CDTDebugModelPresentation.0" ) ); //$NON-NLS-1$ + return label.toString(); + } + } + if ( element instanceof IDisconnect ) { + if ( ((IDisconnect)element).isDisconnected() ) { + label.insert( 0, CDebugUIMessages.getString( "CDTDebugModelPresentation.1" ) ); //$NON-NLS-1$ + return label.toString(); + } + } + if ( label.length() > 0 ) { + return label.toString(); + } } - if ( element instanceof IRegisterGroup ) { - label.append( getRegisterGroupText( (IRegisterGroup)element ) ); - return label.toString(); + catch( DebugException e ) { + return MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.2" ), new String[] { e.getMessage() } ); //$NON-NLS-1$ } - - if ( label.length() > 0 ) { - return label.toString(); + catch( CoreException e ) { + CDebugUIPlugin.log( e ); } - return getDefaultText( element ); } @@ -212,6 +418,19 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode return label; } + protected String getModuleText( ICModule module, boolean qualified ) { + StringBuffer sb = new StringBuffer(); + IPath path = module.getImageName(); + if ( !path.isEmpty() ) { + sb.append( path.lastSegment() ); + } + 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(); + } + protected String getRegisterGroupText( IRegisterGroup group ) { String name = CDebugUIMessages.getString( "CDebugModelPresentation.not_available_1" ); //$NON-NLS-1$ try { @@ -259,6 +478,132 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode return DebugUIPlugin.getDefaultLabelProvider().getImage( element ); } + + protected IBreakpoint getBreakpoint( IMarker marker ) { + return DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker ); + } + + protected String getBreakpointText( IBreakpoint breakpoint, boolean qualified ) throws CoreException { + if ( breakpoint instanceof ICAddressBreakpoint ) { + return getAddressBreakpointText( (ICAddressBreakpoint)breakpoint, qualified ); + } + if ( breakpoint instanceof ICFunctionBreakpoint ) { + return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified ); + } + if ( breakpoint instanceof ICLineBreakpoint ) { + return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified ); + } + if ( breakpoint instanceof ICWatchpoint ) { + return getWatchpointText( (ICWatchpoint)breakpoint, qualified ); + } + return ""; //$NON-NLS-1$ + } + + protected String getLineBreakpointText( ICLineBreakpoint breakpoint, boolean qualified ) throws CoreException { + StringBuffer label = new StringBuffer(); + appendSourceName( breakpoint, label, qualified ); + appendLineNumber( breakpoint, label ); + appendIgnoreCount( breakpoint, label ); + appendCondition( breakpoint, label ); + return label.toString(); + } + + protected String getWatchpointText( ICWatchpoint watchpoint, boolean qualified ) throws CoreException { + StringBuffer label = new StringBuffer(); + appendSourceName( watchpoint, label, qualified ); + appendWatchExpression( watchpoint, label ); + appendIgnoreCount( watchpoint, label ); + appendCondition( watchpoint, label ); + return label.toString(); + } + + protected String getAddressBreakpointText( ICAddressBreakpoint breakpoint, boolean qualified ) throws CoreException { + StringBuffer label = new StringBuffer(); + appendSourceName( breakpoint, label, qualified ); + appendAddress( breakpoint, label ); + appendIgnoreCount( breakpoint, label ); + appendCondition( breakpoint, label ); + return label.toString(); + } + + protected String getFunctionBreakpointText( ICFunctionBreakpoint breakpoint, boolean qualified ) throws CoreException { + StringBuffer label = new StringBuffer(); + appendSourceName( breakpoint, label, qualified ); + appendFunction( breakpoint, label ); + appendIgnoreCount( breakpoint, label ); + appendCondition( breakpoint, label ); + return label.toString(); + } + + protected StringBuffer appendSourceName( ICBreakpoint breakpoint, StringBuffer label, boolean qualified ) throws CoreException { + String handle = breakpoint.getSourceHandle(); + if ( !isEmpty( handle ) ) { + IPath path = new Path( handle ); + if ( path.isValidPath( handle ) ) { + label.append( qualified ? path.toOSString() : path.lastSegment() ); + } + } + return label; + } + + protected StringBuffer appendLineNumber( ICLineBreakpoint breakpoint, StringBuffer label ) throws CoreException { + int lineNumber = breakpoint.getLineNumber(); + if ( lineNumber > 0 ) { + label.append( ' ' ); + label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.26" ), new String[]{ Integer.toString( lineNumber ) } ) ); //$NON-NLS-1$ + } + return label; + } + + protected StringBuffer appendAddress( ICAddressBreakpoint breakpoint, StringBuffer label ) throws CoreException { + try { + label.append( ' ' ); + label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.27" ), new String[]{ breakpoint.getAddress() } ) ); //$NON-NLS-1$ + } + catch( NumberFormatException e ) { + } + return label; + } + + protected StringBuffer appendFunction( ICFunctionBreakpoint breakpoint, StringBuffer label ) throws CoreException { + String function = breakpoint.getFunction(); + if ( function != null && function.trim().length() > 0 ) { + label.append( ' ' ); + label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.28" ), new String[]{ function.trim() } ) ); //$NON-NLS-1$ + } + return label; + } + + protected StringBuffer appendIgnoreCount( ICBreakpoint breakpoint, StringBuffer label ) throws CoreException { + int ignoreCount = breakpoint.getIgnoreCount(); + if ( ignoreCount > 0 ) { + label.append( ' ' ); + label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.29" ), new String[]{ Integer.toString( ignoreCount ) } ) ); //$NON-NLS-1$ + } + return label; + } + + protected void appendCondition( ICBreakpoint breakpoint, StringBuffer buffer ) throws CoreException { + String condition = breakpoint.getCondition(); + if ( condition != null && condition.length() > 0 ) { + buffer.append( ' ' ); + buffer.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.30" ) ); //$NON-NLS-1$ + buffer.append( ' ' ); + buffer.append( condition ); + } + } + + private void appendWatchExpression( ICWatchpoint watchpoint, StringBuffer label ) throws CoreException { + String expression = watchpoint.getExpression(); + if ( expression != null && expression.length() > 0 ) { + label.append( ' ' ); + label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.31" ) ); //$NON-NLS-1$ + label.append( " \'" ); //$NON-NLS-1$ + label.append( expression ); + label.append( '\'' ); + } + } + private ImageDescriptor[] computeBreakpointOverlays( ICBreakpoint breakpoint ) { ImageDescriptor[] overlays = new ImageDescriptor[]{ null, null, null, null }; try { @@ -280,4 +625,330 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode } return overlays; } + + + protected Image getVariableImage( IVariable element ) { + if ( element instanceof ICVariable ) { + ICType type = null; + try { + type = ((ICVariable)element).getType(); + } + catch( DebugException e ) { + // use default image + } + if ( type != null && (type.isPointer() || type.isReference()) ) + return fDebugImageRegistry.get( (((ICVariable)element).isEnabled()) ? CDebugImages.DESC_OBJS_VARIABLE_POINTER : CDebugImages.DESC_OBJS_VARIABLE_POINTER_DISABLED ); + else if ( type != null && (type.isArray() || type.isStructure()) ) + return fDebugImageRegistry.get( (((ICVariable)element).isEnabled()) ? CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE : CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE_DISABLED ); + else + return fDebugImageRegistry.get( (((ICVariable)element).isEnabled()) ? CDebugImages.DESC_OBJS_VARIABLE_SIMPLE : CDebugImages.DESC_OBJS_VARIABLE_SIMPLE_DISABLED ); + } + return null; + } + + protected Image getRegisterImage( IRegister element ) { + return ( ( element instanceof ICVariable && ((ICVariable)element).isEnabled() ) ) ? fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER ) : fDebugImageRegistry.get( CDebugImages.DESC_OBJS_REGISTER_DISABLED ); + } + + protected Image getExpressionImage( IExpression element ) { + 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: + if ( element.areSymbolsLoaded() ) { + return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_EXECUTABLE_WITH_SYMBOLS ); + } + return CDebugUIPlugin.getImageDescriptorRegistry().get( CDebugImages.DESC_OBJS_EXECUTABLE ); + case ICModule.SHARED_LIBRARY: + if ( element.areSymbolsLoaded() ) { + return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.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 ); + } + return null; + } + + private String getVariableTypeName( ICType type ) { + StringBuffer result = new StringBuffer(); + String typeName = type.getName(); + if ( typeName != null ) + typeName = typeName.trim(); + if ( type.isArray() && typeName != null ) { + int index = typeName.indexOf( '[' ); + if ( index != -1 ) + typeName = typeName.substring( 0, index ).trim(); + } + if ( typeName != null && typeName.length() > 0 ) { + result.append( typeName ); + if ( type.isArray() ) { + int[] dims = type.getArrayDimensions(); + for( int i = 0; i < dims.length; ++i ) { + result.append( '[' ); + result.append( dims[i] ); + result.append( ']' ); + } + } + } + return result.toString(); + } + + protected String getVariableText( IVariable var ) throws DebugException { + StringBuffer label = new StringBuffer(); + if ( var instanceof ICVariable ) { + ICType type = null; + try { + type = ((ICVariable)var).getType(); + } + catch( DebugException e ) { + // don't display type + } + if ( type != null && isShowVariableTypeNames() ) { + String typeName = getVariableTypeName( type ); + if ( typeName != null && typeName.length() > 0 ) { + label.append( typeName ).append( ' ' ); + } + } + String name = var.getName(); + if ( name != null ) + label.append( name.trim() ); + IValue value = var.getValue(); + if ( value != null ) { + String valueString = getValueText( value ); + if ( !isEmpty( valueString ) ) { + label.append( " = " ); //$NON-NLS-1$ + label.append( valueString ); + } + } + } + return label.toString(); + } + + protected String getValueText( IValue value )/* throws DebugException*/ { + StringBuffer label = new StringBuffer(); + if ( value instanceof ICDebugElementStatus && !((ICDebugElementStatus)value).isOK() ) { + label.append( getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.4" ), ((ICDebugElementStatus)value).getMessage() ) ); //$NON-NLS-1$ + } + else if ( value instanceof ICValue ) { + ICType type = null; + try { + type = ((ICValue)value).getType(); + } + catch( DebugException e ) { + } + try { + String valueString = value.getValueString(); + if ( valueString != null ) { + valueString = valueString.trim(); + if ( type != null && type.isCharacter() ) { + if ( valueString.length() == 0 ) + valueString = "."; //$NON-NLS-1$ + label.append( valueString ); + } + else if ( type != null && type.isFloatingPointType() ) { + Number floatingPointValue = CDebugUtils.getFloatingPointValue( (ICValue)value ); + if ( CDebugUtils.isNaN( floatingPointValue ) ) + valueString = "NAN"; //$NON-NLS-1$ + if ( CDebugUtils.isPositiveInfinity( floatingPointValue ) ) + valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.23" ); //$NON-NLS-1$ + if ( CDebugUtils.isNegativeInfinity( floatingPointValue ) ) + valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.24" ); //$NON-NLS-1$ + label.append( valueString ); + } + else if ( type == null || (!type.isArray() && !type.isStructure()) ) { + if ( valueString.length() > 0 ) { + label.append( valueString ); + } + } + } + } + catch( DebugException e1 ) { + } + } + return label.toString(); + } + + protected String getSignalText( ICSignal signal ) { + StringBuffer sb = new StringBuffer( CDebugUIMessages.getString( "CDTDebugModelPresentation.12" ) ); //$NON-NLS-1$ + try { + String name = signal.getName(); + sb.append( " \'" ).append( name ).append( '\'' ); //$NON-NLS-1$ + } + catch( DebugException e ) { + } + return sb.toString(); + } + + protected String getWatchExpressionText( IWatchExpression expression ) { + StringBuffer result = new StringBuffer(); + result.append( '"' ).append( expression.getExpressionText() ).append( '"' ); + if ( expression.isPending() ) { + result.append( " = " ).append( "..." ); //$NON-NLS-1$//$NON-NLS-2$ + } + else { + IValue value = expression.getValue(); + if ( value instanceof ICValue ) { + ICType type = null; + try { + type = ((ICValue)value).getType(); + } + catch( DebugException e1 ) { + } + if ( type != null && isShowVariableTypeNames() ) { + String typeName = getVariableTypeName( type ); + if ( !isEmpty( typeName ) ) { + result.insert( 0, typeName + ' ' ); + } + } + if ( expression.isEnabled() ) { + String valueString = getValueText( value ); + if ( valueString.length() > 0 ) { + result.append( " = " ).append( valueString ); //$NON-NLS-1$ + } + } + } + } + if ( !expression.isEnabled() ) { + result.append( ' ' ); + result.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.22" ) ); //$NON-NLS-1$ + } + return result.toString(); + } + + protected String getTargetText( IDebugTarget target, boolean qualified ) throws DebugException { + ICDebugTarget t = (ICDebugTarget)target.getAdapter( ICDebugTarget.class ); + if ( t != null ) { + if ( !t.isPostMortem() ) { + CDebugElementState state = t.getState(); + if ( state.equals( CDebugElementState.EXITED ) ) { + Object info = t.getCurrentStateInfo(); + String label = CDebugUIMessages.getString( "CDTDebugModelPresentation.3" ); //$NON-NLS-1$ + String reason = ""; //$NON-NLS-1$ + if ( info != null && info instanceof ICDISignalExitInfo ) { + ICDISignalExitInfo sigInfo = (ICDISignalExitInfo)info; + reason = ' ' + MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.5" ), new String[]{ sigInfo.getName(), sigInfo.getDescription() } ); //$NON-NLS-1$ + } + else if ( info != null && info instanceof ICDIExitInfo ) { + reason = ' ' + MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.6" ), new Integer[] { new Integer( ((ICDIExitInfo)info).getCode() ) } ); //$NON-NLS-1$ + } + return MessageFormat.format( label, new String[] { target.getName(), reason } ); + } + else if ( state.equals( CDebugElementState.SUSPENDED ) ) { + return MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.7" ), new String[] { target.getName() } ); //$NON-NLS-1$ + } + } + } + return target.getName(); + } + + protected String getThreadText( IThread thread, boolean qualified ) throws DebugException { + ICDebugTarget target = (ICDebugTarget)thread.getDebugTarget().getAdapter( ICDebugTarget.class ); + if ( target.isPostMortem() ) { + return getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.8" ), thread.getName() ); //$NON-NLS-1$ + } + if ( thread.isTerminated() ) { + return getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.9" ), thread.getName() ); //$NON-NLS-1$ + } + if ( thread.isStepping() ) { + return getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.10" ), thread.getName() ); //$NON-NLS-1$ + } + if ( !thread.isSuspended() ) { + return getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.11" ), thread.getName() ); //$NON-NLS-1$ + } + if ( thread.isSuspended() ) { + String reason = ""; //$NON-NLS-1$ + ICDebugElement element = (ICDebugElement)thread.getAdapter( ICDebugElement.class ); + if ( element != null ) { + Object info = element.getCurrentStateInfo(); + if ( info != null && info instanceof ICDISignalReceived ) { + ICDISignal signal = ((ICDISignalReceived)info).getSignal(); + reason = MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.13" ), new String[]{ signal.getName(), signal.getDescription() } ); //$NON-NLS-1$ + } + else if ( info != null && info instanceof ICDIWatchpointTrigger ) { + reason = MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.14" ), new String[]{ ((ICDIWatchpointTrigger)info).getOldValue(), ((ICDIWatchpointTrigger)info).getNewValue() } ); //$NON-NLS-1$ + } + else if ( info != null && info instanceof ICDIWatchpointScope ) { + reason = CDebugUIMessages.getString( "CDTDebugModelPresentation.15" ); //$NON-NLS-1$ + } + else if ( info != null && info instanceof ICDIBreakpointHit ) { + reason = CDebugUIMessages.getString( "CDTDebugModelPresentation.16" ); //$NON-NLS-1$ + } + else if ( info != null && info instanceof ICDISharedLibraryEvent ) { + reason = CDebugUIMessages.getString( "CDTDebugModelPresentation.17" ); //$NON-NLS-1$ + } + } + return MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.18" ), new String[] { thread.getName(), reason } ); //$NON-NLS-1$ + } + return MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.19" ), new String[] { thread.getName() } ); //$NON-NLS-1$ + } + + protected String getStackFrameText( IStackFrame f, boolean qualified ) throws DebugException { + if ( f instanceof ICStackFrame ) { + ICStackFrame frame = (ICStackFrame)f; + StringBuffer label = new StringBuffer(); + label.append( frame.getLevel() ); + label.append( ' ' ); + String function = frame.getFunction(); + if ( function != null ) { + function = function.trim(); + if ( function.length() > 0 ) { + label.append( function ); + label.append( "() " ); //$NON-NLS-1$ + if ( frame.getFile() != null ) { + IPath path = new Path( frame.getFile() ); + if ( !path.isEmpty() ) { + label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.20" ) ); //$NON-NLS-1$ + label.append( ' ' ); + label.append( (qualified ? path.toOSString() : path.lastSegment()) ); + label.append( ':' ); + if ( frame.getFrameLineNumber() != 0 ) + label.append( frame.getFrameLineNumber() ); + } + } + } + } + if ( isEmpty( function ) ) + label.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.21" ) ); //$NON-NLS-1$ + return label.toString(); + } + return (f.getAdapter( IDummyStackFrame.class ) != null) ? getDummyStackFrameLabel( f ) : f.getName(); + } + + private String getDummyStackFrameLabel( IStackFrame stackFrame ) { + return DUMMY_STACKFRAME_LABEL; + } + + protected boolean isShowVariableTypeNames() { + Boolean show = (Boolean)fAttributes.get( DISPLAY_VARIABLE_TYPE_NAMES ); + show = show == null ? Boolean.FALSE : show; + return show.booleanValue(); + } + + public static String getFormattedString( String key, String arg ) { + return getFormattedString( key, new String[]{ arg } ); + } + + public static String getFormattedString( String string, String[] args ) { + return MessageFormat.format( string, args ); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() + */ + public void dispose() { + getImageCache().disposeAll(); + fAttributes.clear(); + super.dispose(); + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.properties index 5d456d9843a..d7b5dbd8999 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.properties @@ -10,6 +10,8 @@ ############################################################################### CDebugModelPresentation.unknown_1=unknown +CDebugModelPresentation.0=\ (symbols loaded) +CDebugModelPresentation.1=\ (symbols not loaded) CDebugImageDescriptorRegistry.0=Allocating image for wrong display. CDebugModelPresentation.not_available_1= CDTDebugModelPresentation.0= diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java index defc363c43c..7be61d102bb 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/ICDebugHelpContextIds.java @@ -48,10 +48,12 @@ public interface ICDebugHelpContextIds public static final String TOGGLE_BREAKPOINT_ACTION = PREFIX + "manage_breakpoint_action_context"; //$NON-NLS-1$ public static final String ENABLE_DISABLE_BREAKPOINT_ACTION = PREFIX + "enable_disable_breakpoint_action_context"; //$NON-NLS-1$ public static final String BREAKPOINT_PROPERTIES_ACTION = PREFIX + "breakpoint_properties_action_context"; //$NON-NLS-1$ + public static final String SHOW_DETAIL_PANE_ACTION = PREFIX + "show_detail_pane_action_context"; //$NON-NLS-1$ // Views 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$ + public static final String MODULES_VIEW = PREFIX + "modules_view_context"; //$NON-NLS-1$ public static final String SIGNALS_VIEW = PREFIX + "signals_view_context"; //$NON-NLS-1$ public static final String DISASSEMBLY_VIEW = PREFIX + "disassembly_view_context"; //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties index c73b7e351d1..659d1fcc8ba 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties @@ -95,3 +95,11 @@ ResumeAtLineAdapter.1=Missing document ResumeAtLineAdapter.2=Empty editor ResumeAtLineAdapter.3=Operation is not supported. ResumeAtLineAdapter.4=Resume At Line failed. +ToggleDetailPaneAction.0=Vertical View Orientation +ToggleDetailPaneAction.1=Place the Detail Pane Underneath the Main Tree View +ToggleDetailPaneAction.2=Place the Detail Pane Underneath the Main Tree View +ToggleDetailPaneAction.3=Horizontal View Orientation +ToggleDetailPaneAction.4=Place the Detail Pane on the Right of the Main Tree View +ToggleDetailPaneAction.5=Place the Detail Pane on the Right of the Main Tree View +ToggleDetailPaneAction.6=Hide the Detail Pane so that only the Main Tree View is Visible +ToggleDetailPaneAction.7=Hide the Detail Pane so that only the Main Tree View is Visible diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CollapseAllModulesAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CollapseAllModulesAction.java new file mode 100644 index 00000000000..518aa330dad --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CollapseAllModulesAction.java @@ -0,0 +1,52 @@ +/********************************************************************** + * 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.debug.ui.IDebugView; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.util.Assert; +import org.eclipse.jface.viewers.AbstractTreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.actions.ActionDelegate; + +/** + * The delegate for the "Collapse All" action of the Modules view. + */ +public class CollapseAllModulesAction extends ActionDelegate implements IViewActionDelegate { + + private IDebugView fView; + + /* (non-Javadoc) + * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) + */ + public void init( IViewPart view ) { + Assert.isLegal( view instanceof IDebugView ); + fView = (IDebugView)view; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run( IAction action ) { + Viewer viewer = getView().getViewer(); + if ( viewer instanceof AbstractTreeViewer ) { + viewer.getControl().setRedraw( false ); + ((AbstractTreeViewer)viewer).collapseToLevel( viewer.getInput(), AbstractTreeViewer.ALL_LEVELS ); + viewer.getControl().setRedraw(true); + } + } + + private IDebugView getView() { + return fView; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleDetailPaneAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleDetailPaneAction.java new file mode 100644 index 00000000000..c495e74d8d7 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleDetailPaneAction.java @@ -0,0 +1,88 @@ +/********************************************************************** + * 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.internal.ui.CDebugImages; +import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds; +import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants; +import org.eclipse.cdt.debug.internal.ui.views.modules.ModulesView; +import org.eclipse.jface.action.Action; +import org.eclipse.ui.help.WorkbenchHelp; + +/** + * Action that controls the appearance of the details pane in debug views + * such as the modules view. Instances of this class can be created to show + * the detail pane underneath the main tree, to the right of the main tree, + * or not shown at all. + */ +public class ToggleDetailPaneAction extends Action { + + private ModulesView fModulesView; + + private String fOrientation; + + /** + * Constructor for ToggleDetailPaneAction. + */ + public ToggleDetailPaneAction( ModulesView view, String orientation, String hiddenLabel ) { + super( "", AS_RADIO_BUTTON ); //$NON-NLS-1$ + setModulesView( view ); + setOrientation( orientation ); + if ( orientation == ICDebugPreferenceConstants.MODULES_DETAIL_PANE_UNDERNEATH ) { + setText( ActionMessages.getString( "ToggleDetailPaneAction.0" ) ); //$NON-NLS-1$ + setToolTipText( ActionMessages.getString( "ToggleDetailPaneAction.1" ) ); //$NON-NLS-1$ + setDescription( ActionMessages.getString( "ToggleDetailPaneAction.2" ) ); //$NON-NLS-1$ + setImageDescriptor( CDebugImages.DESC_LCL_DETAIL_PANE_UNDER ); + setDisabledImageDescriptor( CDebugImages.DESC_LCL_DETAIL_PANE_UNDER_DISABLED ); + setHoverImageDescriptor( CDebugImages.DESC_LCL_DETAIL_PANE_UNDER ); + } + else if ( orientation == ICDebugPreferenceConstants.MODULES_DETAIL_PANE_RIGHT ) { + setText( ActionMessages.getString( "ToggleDetailPaneAction.3" ) ); //$NON-NLS-1$ + setToolTipText( ActionMessages.getString( "ToggleDetailPaneAction.4" ) ); //$NON-NLS-1$ + setDescription( ActionMessages.getString( "ToggleDetailPaneAction.5" ) ); //$NON-NLS-1$ + setImageDescriptor( CDebugImages.DESC_LCL_DETAIL_PANE_RIGHT ); + setDisabledImageDescriptor( CDebugImages.DESC_LCL_DETAIL_PANE_RIGHT_DISABLED ); + setHoverImageDescriptor( CDebugImages.DESC_LCL_DETAIL_PANE_RIGHT ); + } + else { + setText( hiddenLabel ); + setToolTipText( ActionMessages.getString( "ToggleDetailPaneAction.6" ) ); //$NON-NLS-1$ + setDescription( ActionMessages.getString( "ToggleDetailPaneAction.7" ) ); //$NON-NLS-1$ + setImageDescriptor( CDebugImages.DESC_LCL_DETAIL_PANE_HIDE ); + setDisabledImageDescriptor( CDebugImages.DESC_LCL_DETAIL_PANE_HIDE_DISABLED ); + setHoverImageDescriptor( CDebugImages.DESC_LCL_DETAIL_PANE_HIDE ); + } + WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.SHOW_DETAIL_PANE_ACTION ); + } + + private ModulesView getModulesView() { + return fModulesView; + } + + private void setModulesView( ModulesView modulesView ) { + fModulesView = modulesView; + } + + private void setOrientation( String orientation ) { + fOrientation = orientation; + } + + public String getOrientation() { + return fOrientation; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IAction#run() + */ + public void run() { + getModulesView().setDetailPaneOrientation( getOrientation() ); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java index 94d65174c18..d33a0112402 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java @@ -13,16 +13,11 @@ package org.eclipse.cdt.debug.internal.ui.preferences; import org.eclipse.cdt.debug.ui.ICDebugUIConstants; /** - * * Constants defining the keys to be used for accessing preferences inside the debug ui plugin's preference bundle. - * - * In descriptions (of the keys) below describe the preference stored at the given key. The type indicates type of the stored preferences - * + * In descriptions (of the keys) below describe the preference stored at the given key. + * The type indicates type of the stored preferences * The preference store is loaded by the plugin (CDebugUIPlugin). - * * @see CDebugUIPlugin.initializeDefaultPreferences(IPreferenceStore) - for initialization of the store - * - * @since Jul 23, 2002 */ public interface ICDebugPreferenceConstants { @@ -40,4 +35,15 @@ public interface ICDebugPreferenceConstants { * Boolean preference controlling whether primitive types types display char values. */ public static final String PREF_SHOW_CHAR_VALUES = ICDebugUIConstants.PLUGIN_ID + ".cDebug.showCharValues"; //$NON-NLS-1$ + + /** + * The orientation of the detail view in the ModulesView + */ + public static final String MODULES_DETAIL_PANE_ORIENTATION = "Modules.detail.orientation"; //$NON-NLS-1$ + + public static final String MODULES_DETAIL_PANE_RIGHT = "Modules.detail.orientation.right"; //$NON-NLS-1$ + + public static final String MODULES_DETAIL_PANE_UNDERNEATH = "Modules.detail.orientation.underneath"; //$NON-NLS-1$ + + public static final String MODULES_DETAIL_PANE_HIDDEN = "Modules.detail.orientation.hidden"; //$NON-NLS-1$ } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/DebugViewDecoratingLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/DebugViewDecoratingLabelProvider.java new file mode 100644 index 00000000000..44f1efcfe4a --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/DebugViewDecoratingLabelProvider.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.ui.views; + +import java.util.HashMap; +import java.util.Map; +import org.eclipse.jface.viewers.DecoratingLabelProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.StructuredViewer; + +/** + * A label provider which receives notification of labels computed in + * the background by a LaunchViewLabelDecorator. + */ +public class DebugViewDecoratingLabelProvider extends DecoratingLabelProvider { + + /** + * A map of text computed for elements. Items are added to this map + * when notification is received that text has been computed for an element + * and they are removed the first time the text is returned for an + * element. + * key: Object the element + * value: String the label text + */ + private Map computedText= new HashMap(); + private StructuredViewer viewer= null; + private boolean disposed= false; + + /** + * @see DecoratingLabelProvider#DecoratingLabelProvider(org.eclipse.jface.viewers.ILabelProvider, org.eclipse.jface.viewers.ILabelDecorator) + */ + public DebugViewDecoratingLabelProvider(StructuredViewer viewer, ILabelProvider provider, DebugViewLabelDecorator decorator) { + super(provider, decorator); + decorator.setLabelProvider(this); + this.viewer= viewer; + } + + /** + * Notifies this label provider that the given text was computed + * for the given element. The given text will be returned the next + * time its text is requested. + * + * @param element the element whose label was computed + * @param text the label + */ + public void textComputed(Object element, String text) { + computedText.put(element, text); + } + + /** + * Labels have been computed for the given block of elements. + * This method tells the label provider to update the + * given elements in the view. + * + * @param elements the elements which have had their text computed + */ + public void labelsComputed(Object[] elements) { + if (!disposed) { + viewer.update(elements, null); + } + for (int i = 0; i < elements.length; i++) { + computedText.remove(elements[i]); + } + } + + /** + * Returns the stored text computed by the background decorator + * or delegates to the decorating label provider to compute text. + * The stored value is not cleared - the value is cleared when + * #lablesComputed(...) has completed the update of its elements. + * + * @see DecoratingLabelProvider#getText(java.lang.Object) + */ + public String getText(Object element) { + String text= (String) computedText.get(element); + if (text != null) { + return text; + } + return super.getText(element); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() + */ + public void dispose() { + disposed= true; + super.dispose(); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/DebugViewInterimLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/DebugViewInterimLabelProvider.java new file mode 100644 index 00000000000..d69e613aa89 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/DebugViewInterimLabelProvider.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.ui.views; + +import org.eclipse.debug.ui.IDebugModelPresentation; +import org.eclipse.jface.viewers.IColorProvider; +import org.eclipse.jface.viewers.IFontProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; + +/** + * A label provider that provide interim text labels. When queried for text, the label provider + * returns a default string (""). When queried for images, the label provider + * queries a debug model presentation. This label provider is intended to be passed to + * a DebugViewDecoratingLabelProvider. + */ +public class DebugViewInterimLabelProvider implements ILabelProvider, IColorProvider, IFontProvider { + + /** + * The text label returned by this label provider (value: "..."). + */ + public final static String PENDING_LABEL= "..."; //$NON-NLS-1$ + + /** + * The debug model presentation used for computing images. + */ + protected IDebugModelPresentation presentation; + + /** + * Creates a new interim label provider with the given model presentation. + * + * @param presentation the model presentation to use for computing images + */ + public DebugViewInterimLabelProvider(IDebugModelPresentation presentation) { + this.presentation= presentation; + } + + /** + * Returns the debug model presentation used by this label provider + * to compute images. + * + * @return this label provider's model presentation + */ + public IDebugModelPresentation getPresentation() { + return presentation; + } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) + */ + public Image getImage(Object element) { + return presentation.getImage(element); + } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) + */ + public String getText(Object element) { + return DebugViewInterimLabelProvider.PENDING_LABEL; + } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) + */ + public void addListener(ILabelProviderListener listener) { + presentation.addListener(listener); + } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() + */ + public void dispose() { + presentation.dispose(); + } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) + */ + public boolean isLabelProperty(Object element, String property) { + return presentation.isLabelProperty(element, property); + } + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) + */ + public void removeListener(ILabelProviderListener listener) { + presentation.removeListener(listener); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) + */ + public Color getForeground(Object element) { + if (presentation instanceof IColorProvider) { + IColorProvider colorProvider = (IColorProvider) presentation; + return colorProvider.getForeground(element); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) + */ + public Color getBackground(Object element) { + if (presentation instanceof IColorProvider) { + IColorProvider colorProvider = (IColorProvider) presentation; + return colorProvider.getBackground(element); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) + */ + public Font getFont(Object element) { + if (presentation instanceof IFontProvider) { + IFontProvider fontProvider = (IFontProvider) presentation; + return fontProvider.getFont(element); + } + return null; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/DebugViewLabelDecorator.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/DebugViewLabelDecorator.java new file mode 100644 index 00000000000..5732a8bf0e4 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/DebugViewLabelDecorator.java @@ -0,0 +1,199 @@ +/********************************************************************** + * 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; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.debug.core.DebugEvent; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.IDebugEventSetListener; +import org.eclipse.debug.ui.IDebugModelPresentation; +import org.eclipse.jface.viewers.ILabelDecorator; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + +/** + * A label decorator which computes text for debug elements + * in the background and updates them asynchronously. + */ +public class DebugViewLabelDecorator extends LabelProvider implements ILabelDecorator, IDebugEventSetListener { + + /** + * The presentation used to compute text. + */ + private IDebugModelPresentation fPresentation; + + /** + * The label provider notified when text is computed. + */ + protected DebugViewDecoratingLabelProvider fLabelProvider; + + /** + * The job which will be executed next. All new label requests + * are appended to this job. + */ + protected LabelJob fNextJob = null; + + /** + * Constructor for DebugViewLabelDecorator. + */ + public DebugViewLabelDecorator( IDebugModelPresentation presentation ) { + fPresentation = presentation; + DebugPlugin.getDefault().addDebugEventListener( this ); + } + + /** + * Sets the label provider which will be notified when a + * label has been computed in the background. + * + * @param labelProvider the label provider to notify when text + * is computed + */ + public void setLabelProvider( DebugViewDecoratingLabelProvider labelProvider ) { + fLabelProvider = labelProvider; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object) + */ + public Image decorateImage( Image image, Object element ) { + return image; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(java.lang.String, java.lang.Object) + */ + public String decorateText( String text, final Object element ) { + computeText( element ); + return text; + } + + public void computeText( Object element ) { + synchronized( this ) { + if ( fNextJob == null ) { + fNextJob = new LabelJob( "Debug", fPresentation ); //$NON-NLS-1$ + } + fNextJob.computeText( element ); + } + } + + public void labelsComputed( final Object[] computedElements ) { + CDebugUIPlugin.getStandardDisplay().asyncExec( + new Runnable() { + + public void run() { + fLabelProvider.labelsComputed( computedElements ); + } + } ); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[]) + */ + public void handleDebugEvents( DebugEvent[] events ) { + } + + /** + * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() + */ + public void dispose() { + super.dispose(); + DebugPlugin.getDefault().removeDebugEventListener( this ); + } + + /** + * A job which computes text for a queue of elements. The job's label + * decorator is notified when text has been computed for some number + * of elements. + */ + protected class LabelJob extends Job implements ISchedulingRule { + + private Vector fElementQueue = new Vector(); + private IDebugModelPresentation fJobPresentation; + + /** + * Creates a new job with the given name which will use the given + * presentation to compute labels in the background + * @param name the job's name + * @param presentation the presentation to use for label + * computation + */ + public LabelJob( String name, IDebugModelPresentation presentation ) { + super( name ); + fJobPresentation = presentation; + setSystem( true ); + } + + /** + * Queues up the given element to have its text computed. + * @param element the element whose text should be computed + * in this background job + */ + public void computeText( Object element ) { + if ( !fElementQueue.contains( element ) ) { + fElementQueue.add( element ); + } + schedule(); + } + + /* (non-Javadoc) + * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor) + */ + public IStatus run( IProgressMonitor monitor ) { + int numElements = fElementQueue.size(); + monitor.beginTask( MessageFormat.format( "Fetching {0} labels", new String[]{ Integer.toString( numElements ) } ), numElements ); //$NON-NLS-1$ + while( !fElementQueue.isEmpty() && !monitor.isCanceled() ) { + StringBuffer message = new StringBuffer( MessageFormat.format( "Fetching {0} labels", new String[]{ Integer.toString( fElementQueue.size() ) } ) ); //$NON-NLS-1$ + message.append( MessageFormat.format( " ({0} pending)", new String[]{ Integer.toString( fNextJob.fElementQueue.size() ) } ) ); //$NON-NLS-1$ + monitor.setTaskName( message.toString() ); + int blockSize = 10; + if ( fElementQueue.size() < blockSize ) { + blockSize = fElementQueue.size(); + } + final List computedElements = new ArrayList(); + for( int i = 0; i < blockSize; i++ ) { + Object element = fElementQueue.remove( 0 ); + if ( element == null ) { + break; + } + fLabelProvider.textComputed( element, fJobPresentation.getText( element ) ); + computedElements.add( element ); + } + labelsComputed( computedElements.toArray() ); + monitor.worked( computedElements.size() ); + } + monitor.done(); + return Status.OK_STATUS; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule) + */ + public boolean contains( ISchedulingRule rule ) { + return (rule instanceof LabelJob) && fJobPresentation == ((LabelJob)rule).fJobPresentation; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule) + */ + public boolean isConflicting( ISchedulingRule rule ) { + return (rule instanceof LabelJob) && fJobPresentation == ((LabelJob)rule).fJobPresentation; + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesMessages.java new file mode 100644 index 00000000000..bd515a4ae05 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesMessages.java @@ -0,0 +1,37 @@ +/********************************************************************** + * 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.modules; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Comment for . + */ +public class ModulesMessages { + + private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.modules.ModulesMessages";//$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + + private ModulesMessages() { + } + + public static String getString( String key ) { + // TODO Auto-generated method stub + try { + return RESOURCE_BUNDLE.getString( key ); + } + catch( MissingResourceException e ) { + return '!' + key + '!'; + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesMessages.properties new file mode 100644 index 00000000000..b545cd96d43 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesMessages.properties @@ -0,0 +1,8 @@ +ModulesView.0=Modules View Only +ModulesView.1=executable +ModulesView.2=shared library +ModulesView.3=Type: +ModulesView.4=Symbols: +ModulesView.5=loaded +ModulesView.6=not loaded +ModulesView.7=Symbols file: diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesView.java new file mode 100644 index 00000000000..1ff3496c146 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesView.java @@ -0,0 +1,801 @@ +/********************************************************************** + * 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.modules; + +import org.eclipse.cdt.debug.core.model.ICDebugElement; +import org.eclipse.cdt.debug.core.model.ICDebugTarget; +import org.eclipse.cdt.debug.core.model.ICModule; +import org.eclipse.cdt.debug.internal.ui.CDebugModelPresentation; +import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds; +import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants; +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.DebugViewDecoratingLabelProvider; +import org.eclipse.cdt.debug.internal.ui.views.DebugViewInterimLabelProvider; +import org.eclipse.cdt.debug.internal.ui.views.DebugViewLabelDecorator; +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.DebugPlugin; +import org.eclipse.debug.ui.IDebugModelPresentation; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.DocumentEvent; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IDocumentListener; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.jface.text.source.SourceViewer; +import org.eclipse.jface.text.source.SourceViewerConfiguration; +import org.eclipse.jface.util.IPropertyChangeListener; +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.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; +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.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.IMemento; +import org.eclipse.ui.INullSelectionListener; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.texteditor.IUpdate; + +/** + * Displays the modules currently loaded by the process being debugged. + */ +public class ModulesView extends AbstractDebugEventHandlerView implements IDebugExceptionHandler, IPropertyChangeListener, ISelectionListener, INullSelectionListener { + + /** + * Internal interface for a cursor listener. I.e. aggregation + * of mouse and key listener. + */ + interface ICursorListener extends MouseListener, KeyListener { + } + + /** + * The selection provider for the modules view changes depending on whether + * the variables viewer or detail pane source viewer have focus. This "super" + * provider ensures the correct selection is sent to all listeners. + */ + public class ModulesViewSelectionProvider implements ISelectionProvider { + + private ListenerList fListeners= new ListenerList(); + + private ISelectionProvider fUnderlyingSelectionProvider; + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) + */ + public void addSelectionChangedListener( ISelectionChangedListener listener ) { + fListeners.add( listener ); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() + */ + public ISelection getSelection() { + return getUnderlyingSelectionProvider().getSelection(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) + */ + public void removeSelectionChangedListener( ISelectionChangedListener listener ) { + fListeners.remove( listener ); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) + */ + public void setSelection( ISelection selection ) { + getUnderlyingSelectionProvider().setSelection( selection ); + } + + protected ISelectionProvider getUnderlyingSelectionProvider() { + return fUnderlyingSelectionProvider; + } + + protected void setUnderlyingSelectionProvider( ISelectionProvider underlyingSelectionProvider ) { + fUnderlyingSelectionProvider = underlyingSelectionProvider; + } + + protected void fireSelectionChanged( SelectionChangedEvent event ) { + Object[] listeners = fListeners.getListeners(); + for( int i = 0; i < listeners.length; i++ ) { + ISelectionChangedListener listener = (ISelectionChangedListener)listeners[i]; + listener.selectionChanged( event ); + } + } + } + + /** + * The UI construct that provides a sliding sash between the modules tree + * and the detail pane. + */ + private SashForm fSashForm; + + /** + * The detail pane viewer. + */ + private ISourceViewer fDetailViewer; + + /** + * The document associated with the detail pane viewer. + */ + private IDocument fDetailDocument; + + /** + * The configuration being used in the details area + */ + private SourceViewerConfiguration fSourceViewerConfiguration; + + /** + * Selection provider for this view. + */ + private ModulesViewSelectionProvider fSelectionProvider = new ModulesViewSelectionProvider(); + + /** + * The model presentation used as the label provider for the tree viewer, + * and also as the detail information provider for the detail pane. + */ + private IDebugModelPresentation fModelPresentation; + + /** + * Remembers which viewer (tree viewer or details viewer) had focus, so we + * can reset the focus properly when re-activated. + */ + private Viewer fFocusViewer = null; + + /** + * Various listeners used to update the enabled state of actions and also to + * populate the detail pane. + */ + private ISelectionChangedListener fTreeSelectionChangedListener; + private ISelectionChangedListener fDetailSelectionChangedListener; + private IDocumentListener fDetailDocumentListener; + + /** + * These are used to initialize and persist the position of the sash that + * separates the tree viewer from the detail pane. + */ + private static final int[] DEFAULT_SASH_WEIGHTS = { 13, 6 }; + private int[] fLastSashWeights; + private boolean fToggledDetailOnce; + private ToggleDetailPaneAction[] fToggleDetailPaneActions; + private String fCurrentDetailPaneOrientation = ICDebugPreferenceConstants.MODULES_DETAIL_PANE_HIDDEN; + protected static final String SASH_WEIGHTS = CDebugUIPlugin.getUniqueIdentifier() + ".modulesView.SASH_WEIGHTS"; //$NON-NLS-1$ + + private ICursorListener fCursorListener; + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.AbstractDebugView#createViewer(org.eclipse.swt.widgets.Composite) + */ + protected Viewer createViewer( Composite parent ) { + TreeViewer viewer = createTreeViewer( parent ); + createDetailsViewer(); + getSashForm().setMaximizedControl( viewer.getControl() ); + + createOrientationActions(); + IPreferenceStore prefStore = CDebugUIPlugin.getDefault().getPreferenceStore(); + String orientation = prefStore.getString( getDetailPanePreferenceKey() ); + for( int i = 0; i < fToggleDetailPaneActions.length; i++ ) { + fToggleDetailPaneActions[i].setChecked( fToggleDetailPaneActions[i].getOrientation().equals( orientation ) ); + } + setDetailPaneOrientation( orientation ); + + return viewer; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.AbstractDebugView#createActions() + */ + protected void createActions() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.AbstractDebugView#getHelpContextId() + */ + protected String getHelpContextId() { + return ICDebugHelpContextIds.MODULES_VIEW; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.AbstractDebugView#fillContextMenu(org.eclipse.jface.action.IMenuManager) + */ + protected void fillContextMenu( IMenuManager menu ) { + menu.add( new Separator( ICDebugUIConstants.EMPTY_MODULES_GROUP ) ); + menu.add( new Separator( ICDebugUIConstants.MODULES_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(org.eclipse.jface.action.IToolBarManager) + */ + protected void configureToolBar( IToolBarManager tbm ) { + tbm.add( new Separator( ICDebugUIConstants.MODULES_GROUP ) ); + tbm.add( new Separator( ICDebugUIConstants.REFRESH_GROUP ) ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler#handleException(org.eclipse.debug.core.DebugException) + */ + public void handleException( DebugException e ) { + showMessage( e.getMessage() ); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + public void propertyChange( PropertyChangeEvent event ) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.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 ); + } + + protected void setViewerInput( IStructuredSelection ssel ) { + ICDebugTarget target = null; + if ( ssel.size() == 1 ) { + Object input = ssel.getFirstElement(); + if ( input instanceof ICDebugElement ) { + target = (ICDebugTarget)((ICDebugElement)input).getDebugTarget(); + } + } + + Object current = getViewer().getInput(); + if ( current == null && target == null ) { + return; + } + if ( current != null && current.equals( target ) ) { + return; + } + + showViewer(); + getViewer().setInput( target ); + } + + protected TreeViewer createTreeViewer( Composite parent ) { + CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this ); + JFaceResources.getFontRegistry().addListener( this ); + // create the sash form that will contain the tree viewer & text viewer + setSashForm( new SashForm( parent, SWT.NONE ) ); + // add tree viewer + final TreeViewer modulesViewer = new ModulesViewer( getSashForm(), SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL ); + modulesViewer.setContentProvider( createContentProvider() ); + modulesViewer.setLabelProvider( createLabelProvider( modulesViewer ) ); + modulesViewer.setUseHashlookup( true ); + modulesViewer.getControl().addFocusListener( new FocusAdapter() { + + /* (non-Javadoc) + * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent) + */ + public void focusGained( FocusEvent e ) { + getModulesViewSelectionProvider().setUnderlyingSelectionProvider( modulesViewer ); + setFocusViewer( getModulesViewer() ); + } + } ); + modulesViewer.addPostSelectionChangedListener( getTreeSelectionChangedListener() ); + getModulesViewSelectionProvider().setUnderlyingSelectionProvider( modulesViewer ); + getSite().setSelectionProvider( getModulesViewSelectionProvider() ); + // listen to selection in debug view + getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); + setEventHandler( createEventHandler() ); + return modulesViewer; + } + + /** + * Create the widgetry for the details viewer. + */ + protected void createDetailsViewer() { + // Create & configure a SourceViewer + SourceViewer detailsViewer = new SourceViewer( getSashForm(), null, SWT.V_SCROLL | SWT.H_SCROLL ); + setDetailViewer( detailsViewer ); + detailsViewer.setDocument( getDetailDocument() ); + detailsViewer.getTextWidget().setFont( JFaceResources.getFont( IInternalCDebugUIConstants.DETAIL_PANE_FONT ) ); + getDetailDocument().addDocumentListener( getDetailDocumentListener() ); + detailsViewer.setEditable( false ); + Control control = detailsViewer.getControl(); + GridData gd = new GridData( GridData.FILL_BOTH ); + control.setLayoutData( gd ); + detailsViewer.getSelectionProvider().addSelectionChangedListener( getDetailSelectionChangedListener() ); + detailsViewer.getControl().addFocusListener( new FocusAdapter() { + + /* (non-Javadoc) + * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent) + */ + public void focusGained( FocusEvent e ) { + getModulesViewSelectionProvider().setUnderlyingSelectionProvider( getDetailViewer().getSelectionProvider() ); + setFocusViewer( (Viewer)getDetailViewer() ); + } + } ); + // add a context menu to the detail area + createDetailContextMenu( detailsViewer.getTextWidget() ); + detailsViewer.getTextWidget().addMouseListener( getCursorListener() ); + detailsViewer.getTextWidget().addKeyListener( getCursorListener() ); + } + + private void setDetailViewer( ISourceViewer viewer ) { + fDetailViewer = viewer; + } + + protected ISourceViewer getDetailViewer() { + return fDetailViewer; + } + + protected SashForm getSashForm() { + return fSashForm; + } + + private void setSashForm( SashForm sashForm ) { + fSashForm = sashForm; + } + + protected IContentProvider createContentProvider() { + ModulesViewContentProvider cp = new ModulesViewContentProvider(); + cp.setExceptionHandler( this ); + return cp; + } + + protected IBaseLabelProvider createLabelProvider( StructuredViewer viewer ) { + return new DebugViewDecoratingLabelProvider( viewer, new DebugViewInterimLabelProvider( getModelPresentation() ), new DebugViewLabelDecorator( getModelPresentation() ) ); + } + + protected IDebugModelPresentation getModelPresentation() { + if ( fModelPresentation == null ) { + fModelPresentation = CDebugModelPresentation.getDefault(); + } + return fModelPresentation; + } + + protected ModulesViewSelectionProvider getModulesViewSelectionProvider() { + return fSelectionProvider; + } + + protected ModulesViewer getModulesViewer() { + return (ModulesViewer)getViewer(); + } + + protected void setFocusViewer( Viewer viewer ) { + fFocusViewer = viewer; + } + + protected Viewer getFocusViewer() { + return fFocusViewer; + } + + /** + * Lazily instantiate and return a selection listener that populates the detail pane, + * but only if the detail is currently visible. + */ + protected ISelectionChangedListener getTreeSelectionChangedListener() { + if ( fTreeSelectionChangedListener == null ) { + fTreeSelectionChangedListener = new ISelectionChangedListener() { + + public void selectionChanged( SelectionChangedEvent event ) { + if ( event.getSelectionProvider().equals( getModulesViewer() ) ) { + getModulesViewSelectionProvider().fireSelectionChanged( event ); + // if the detail pane is not visible, don't waste time retrieving details + if ( getSashForm().getMaximizedControl() == getViewer().getControl() ) { + return; + } + IStructuredSelection selection = (IStructuredSelection)event.getSelection(); + populateDetailPaneFromSelection( selection ); + treeSelectionChanged( event ); + } + } + }; + } + return fTreeSelectionChangedListener; + } + + protected void treeSelectionChanged( SelectionChangedEvent event ) { + } + + /** + * Ask the modules tree for its current selection, and use this to populate + * the detail pane. + */ + public void populateDetailPane() { + if ( isDetailPaneVisible() ) { + Viewer viewer = getViewer(); + if ( viewer != null ) { + IStructuredSelection selection = (IStructuredSelection)viewer.getSelection(); + populateDetailPaneFromSelection( selection ); + } + } + } + + /** + * Show the details associated with the first of the selected elements in the + * detail pane. + */ + protected void populateDetailPaneFromSelection( IStructuredSelection selection ) { + getDetailDocument().set( "" ); //$NON-NLS-1$ + if ( !selection.isEmpty() ) { + computeDetail( selection.getFirstElement() ); + } + } + + /** + * Lazily instantiate and return a selection listener that updates the enabled + * state of the selection oriented actions in this view. + */ + protected ISelectionChangedListener getDetailSelectionChangedListener() { + if ( fDetailSelectionChangedListener == null ) { + fDetailSelectionChangedListener = new ISelectionChangedListener() { + + public void selectionChanged( SelectionChangedEvent event ) { + if ( event.getSelectionProvider().equals( getModulesViewSelectionProvider().getUnderlyingSelectionProvider() ) ) { + getModulesViewSelectionProvider().fireSelectionChanged( event ); + updateSelectionDependentActions(); + } + } + }; + } + return fDetailSelectionChangedListener; + } + + /** + * Lazily instantiate and return a document listener that updates the enabled state + * of the 'Find/Replace' action. + */ + protected IDocumentListener getDetailDocumentListener() { + if ( fDetailDocumentListener == null ) { + fDetailDocumentListener = new IDocumentListener() { + + public void documentAboutToBeChanged( DocumentEvent event ) { + } + + public void documentChanged( DocumentEvent event ) { + } + }; + } + return fDetailDocumentListener; + } + + /** + * Lazily instantiate and return a Document for the detail pane text viewer. + */ + protected IDocument getDetailDocument() { + if ( fDetailDocument == null ) { + fDetailDocument = new Document(); + } + return fDetailDocument; + } + + protected AbstractDebugEventHandler createEventHandler() { + return new ModulesViewEventHandler( this ); + } + + protected void updateSelectionDependentActions() { + } + + protected void updateAction( String actionId ) { + IAction action = getAction( actionId ); + if ( action instanceof IUpdate ) { + ((IUpdate)action).update(); + } + } + + protected void createDetailContextMenu( Control menuControl ) { + MenuManager menuMgr = new MenuManager(); //$NON-NLS-1$ + menuMgr.setRemoveAllWhenShown( true ); + menuMgr.addMenuListener( new IMenuListener() { + + public void menuAboutToShow( IMenuManager mgr ) { + fillDetailContextMenu( mgr ); + } + } ); + Menu menu = menuMgr.createContextMenu( menuControl ); + menuControl.setMenu( menu ); + // register the context menu such that other plugins may contribute to it + getSite().registerContextMenu( ICDebugUIConstants.MODULES_VIEW_DETAIL_ID, menuMgr, getDetailViewer().getSelectionProvider() ); + addContextMenuManager( menuMgr ); + } + + protected void fillDetailContextMenu( IMenuManager menu ) { + menu.add( new Separator( ICDebugUIConstants.MODULES_GROUP ) ); + menu.add( new Separator() ); + menu.add( getAction( ActionFactory.CUT.getId() ) ); + menu.add( getAction( ActionFactory.COPY.getId() + ".Detail" ) ); //$NON-NLS-1$ + menu.add( getAction( ActionFactory.PASTE.getId() ) ); + menu.add( new Separator( "FIND" ) ); //$NON-NLS-1$ + menu.add( getAction( ActionFactory.FIND.getId() ) ); + menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); + } + + private ICursorListener getCursorListener() { + if ( fCursorListener == null ) { + fCursorListener = new ICursorListener() { + + public void keyPressed( KeyEvent e ) { + } + + public void keyReleased( KeyEvent e ) { + } + + public void mouseDoubleClick( MouseEvent e ) { + } + + public void mouseDown( MouseEvent e ) { + } + + public void mouseUp( MouseEvent e ) { + } + }; + } + return fCursorListener; + } + + public void setDetailPaneOrientation( String orientation ) { + if ( orientation.equals( fCurrentDetailPaneOrientation ) ) { + return; + } + if ( orientation.equals( ICDebugPreferenceConstants.MODULES_DETAIL_PANE_HIDDEN ) ) { + hideDetailPane(); + } + else { + int vertOrHoriz = orientation.equals( ICDebugPreferenceConstants.MODULES_DETAIL_PANE_UNDERNEATH ) ? SWT.VERTICAL : SWT.HORIZONTAL; + getSashForm().setOrientation( vertOrHoriz ); + if ( ICDebugPreferenceConstants.MODULES_DETAIL_PANE_HIDDEN.equals( fCurrentDetailPaneOrientation ) ) { + showDetailPane(); + } + } + fCurrentDetailPaneOrientation = orientation; + CDebugUIPlugin.getDefault().getPreferenceStore().setValue( getDetailPanePreferenceKey(), orientation ); + } + + private void hideDetailPane() { + if ( fToggledDetailOnce ) { + setLastSashWeights( getSashForm().getWeights() ); + } + getSashForm().setMaximizedControl( getViewer().getControl() ); + } + + private void showDetailPane() { + getSashForm().setMaximizedControl( null ); + getSashForm().setWeights( getLastSashWeights() ); + populateDetailPane(); + revealTreeSelection(); + fToggledDetailOnce = true; + } + + protected String getDetailPanePreferenceKey() { + return ICDebugPreferenceConstants.MODULES_DETAIL_PANE_ORIENTATION; + } + + protected int[] getLastSashWeights() { + if ( fLastSashWeights == null ) { + fLastSashWeights = DEFAULT_SASH_WEIGHTS; + } + return fLastSashWeights; + } + + protected void setLastSashWeights( int[] weights ) { + fLastSashWeights = weights; + } + + private void createOrientationActions() { + IActionBars actionBars = getViewSite().getActionBars(); + IMenuManager viewMenu = actionBars.getMenuManager(); + fToggleDetailPaneActions = new ToggleDetailPaneAction[3]; + fToggleDetailPaneActions[0] = new ToggleDetailPaneAction( this, ICDebugPreferenceConstants.MODULES_DETAIL_PANE_UNDERNEATH, null ); + fToggleDetailPaneActions[1] = new ToggleDetailPaneAction( this, ICDebugPreferenceConstants.MODULES_DETAIL_PANE_RIGHT, null ); + fToggleDetailPaneActions[2] = new ToggleDetailPaneAction( this, ICDebugPreferenceConstants.MODULES_DETAIL_PANE_HIDDEN, getToggleActionLabel() ); + viewMenu.add( new Separator() ); + viewMenu.add( fToggleDetailPaneActions[0] ); + viewMenu.add( fToggleDetailPaneActions[1] ); + viewMenu.add( fToggleDetailPaneActions[2] ); + viewMenu.add( new Separator() ); + } + + protected String getToggleActionLabel() { + return ModulesMessages.getString( "ModulesView.0" ); //$NON-NLS-1$ + } + + protected boolean isDetailPaneVisible() { + return !fToggleDetailPaneActions[2].isChecked(); + } + + /** + * Make sure the currently selected item in the tree is visible. + */ + protected void revealTreeSelection() { + ModulesViewer viewer = getModulesViewer(); + if ( viewer != null ) { + ISelection selection = viewer.getSelection(); + if ( selection instanceof IStructuredSelection ) { + Object selected = ((IStructuredSelection)selection).getFirstElement(); + if ( selected != null ) { + viewer.reveal( selected ); + } + } + } + } + + /** + * Set on or off the word wrap flag for the detail pane. + */ + public void toggleDetailPaneWordWrap( boolean on ) { + fDetailViewer.getTextWidget().setWordWrap( on ); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IViewPart#saveState(org.eclipse.ui.IMemento) + */ + public void saveState( IMemento memento ) { + super.saveState( memento ); + SashForm sashForm = getSashForm(); + if ( sashForm != null ) { + int[] weights = sashForm.getWeights(); + memento.putInteger( SASH_WEIGHTS + "-Length", weights.length ); //$NON-NLS-1$ + for( int i = 0; i < weights.length; i++ ) { + memento.putInteger( SASH_WEIGHTS + "-" + i, weights[i] ); //$NON-NLS-1$ + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento) + */ + public void init( IViewSite site, IMemento memento ) throws PartInitException { + super.init( site, memento ); + if ( memento != null ) { + Integer bigI = memento.getInteger( SASH_WEIGHTS + "-Length" ); //$NON-NLS-1$ + if ( bigI == null ) { + return; + } + int numWeights = bigI.intValue(); + int[] weights = new int[numWeights]; + for( int i = 0; i < numWeights; i++ ) { + bigI = memento.getInteger( SASH_WEIGHTS + "-" + i ); //$NON-NLS-1$ + if ( bigI == null ) { + return; + } + weights[i] = bigI.intValue(); + } + if ( weights.length > 0 ) { + setLastSashWeights( weights ); + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.AbstractDebugView#getDefaultControl() + */ + protected Control getDefaultControl() { + return getSashForm(); + } + + /* (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 ); + } + } + + private void computeDetail( final Object element ) { + if ( element != null ) { + DebugPlugin.getDefault().asyncExec( new Runnable() { + + public void run() { + detailComputed( element, doComputeDetail( element ) ); + } + } ); + } + } + + protected String doComputeDetail( Object element ) { + if ( element instanceof ICModule ) { + return getModuleDetail( ((ICModule)element) ); + } + return ""; //$NON-NLS-1$ + } + + private String getModuleDetail( ICModule module ) { + StringBuffer sb = new StringBuffer(); + String type = null; + switch( module.getType() ) { + case ICModule.EXECUTABLE: + type = ModulesMessages.getString( "ModulesView.1" ); //$NON-NLS-1$ + break; + case ICModule.SHARED_LIBRARY: + type = ModulesMessages.getString( "ModulesView.2" ); //$NON-NLS-1$ + break; + } + if ( type != null ) { + sb.append( ModulesMessages.getString( "ModulesView.3" ) ); //$NON-NLS-1$ + sb.append( type ); + sb.append( '\n' ); + } + sb.append( ModulesMessages.getString( "ModulesView.4" ) ); //$NON-NLS-1$ + sb.append( ( module.areSymbolsLoaded() ) ? ModulesMessages.getString( "ModulesView.5" ) : ModulesMessages.getString( "ModulesView.6" ) ); //$NON-NLS-1$ //$NON-NLS-2$ + sb.append( '\n' ); + if ( module.areSymbolsLoaded() ) { + sb.append( ModulesMessages.getString( "ModulesView.7" ) ); //$NON-NLS-1$ + sb.append( module.getSymbolsFileName().toOSString() ); + sb.append( '\n' ); + } + return sb.toString(); + } + + protected void detailComputed( Object element, final String result ) { + Runnable runnable = new Runnable() { + + public void run() { + if ( isAvailable() ) { + getDetailDocument().set( result ); + } + } + }; + asyncExec( runnable ); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewContentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewContentProvider.java new file mode 100644 index 00000000000..2de20e6f25a --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewContentProvider.java @@ -0,0 +1,171 @@ +/********************************************************************** + * 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.modules; + +import java.util.HashMap; +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.IBinary; +import org.eclipse.cdt.core.model.IParent; +import org.eclipse.cdt.debug.core.model.ICDebugTarget; +import org.eclipse.cdt.debug.core.model.ICModule; +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 Modules view. + */ +public class ModulesViewContentProvider implements ITreeContentProvider { + + /** + * A table that maps children to their parent element such that this + * content provider can walk back up the parent chain. + */ + private HashMap fParentCache; + + /** + * Handler for exceptions as content is retrieved + */ + private IDebugExceptionHandler fExceptionHandler; + + /** + * Constructor for ModulesViewContentProvider. + */ + public ModulesViewContentProvider() { + setParentCache( new HashMap( 10 ) ); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) + */ + public Object[] getChildren( Object parent ) { + if ( parent instanceof ICDebugTarget ) { + Object[] children = null; + ICDebugTarget target = (ICDebugTarget)parent; + try { + if ( target != null ) + children = target.getModules(); + if ( children != null ) { + cache( parent, children ); + return children; + } + } + catch( DebugException e ) { + if ( getExceptionHandler() != null ) + getExceptionHandler().handleException( e ); + else + CDebugUIPlugin.log( e ); + } + } + else if ( parent instanceof ICModule ) { + IBinary binary = (IBinary)((ICModule)parent).getAdapter( IBinary.class ); + if ( binary != null ) { + try { + return binary.getChildren(); + } + catch( CModelException e ) { + } + } + } + else if ( parent instanceof IParent ) { + try { + return ((IParent)parent).getChildren(); + } + catch( CModelException e ) { + } + } + return new Object[0]; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) + */ + public Object getParent( Object element ) { + return getParentCache().get( element ); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ + public boolean hasChildren( Object parent ) { + if ( parent instanceof ICDebugTarget ) { + try { + ICDebugTarget target = (ICDebugTarget)parent; + return target.hasModules(); + } + catch( DebugException e ) { + CDebugUIPlugin.log( e ); + } + } + else if ( parent instanceof ICModule ) { + IBinary binary = (IBinary)((ICModule)parent).getAdapter( IBinary.class ); + if ( binary != null ) { + return binary.hasChildren(); + } + } + else if ( parent instanceof IParent ) { + return ((IParent)parent).hasChildren(); + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.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(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { + clearCache(); + } + + protected void setExceptionHandler( IDebugExceptionHandler handler ) { + fExceptionHandler = handler; + } + + protected IDebugExceptionHandler getExceptionHandler() { + return fExceptionHandler; + } + + private HashMap getParentCache() { + return fParentCache; + } + + private void setParentCache( HashMap parentCache ) { + fParentCache = parentCache; + } + + protected void cache( Object parent, Object[] children ) { + for ( int i = 0; i < children.length; i++ ) { + getParentCache().put( children[i], parent ); + } + } + + protected void clearCache() { + if ( getParentCache() != null ) { + getParentCache().clear(); + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewEventHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewEventHandler.java new file mode 100644 index 00000000000..01b7e98827f --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewEventHandler.java @@ -0,0 +1,69 @@ +/********************************************************************** + * 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.modules; + +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 Modules view. + */ +public class ModulesViewEventHandler extends AbstractDebugEventHandler { + + /** + * Constructor for ModulesViewEventHandler. + */ + public ModulesViewEventHandler( AbstractDebugView view ) { + super( view ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler#doHandleDebugEvents(org.eclipse.debug.core.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(); + getTreeViewer().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(); + getTreeViewer().refresh( element ); + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewer.java new file mode 100644 index 00000000000..63bb204000c --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/modules/ModulesViewer.java @@ -0,0 +1,54 @@ +/********************************************************************** + * 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.modules; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Tree; + +/** + * The modules viewer used by the Modules view. + */ +public class ModulesViewer extends TreeViewer { + + /** + * Constructor for ModulesViewer. + */ + public ModulesViewer( Composite parent ) { + super( parent ); + } + + /** + * Constructor for ModulesViewer. + */ + public ModulesViewer( Composite parent, int style ) { + super( parent, style ); + } + + /** + * Constructor for ModulesViewer. + */ + public ModulesViewer( Tree tree ) { + super( tree ); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.Viewer#refresh() + */ + public void refresh() { + super.refresh(); + ISelection selection = getSelection(); + if ( !selection.isEmpty() ) { + setSelection( selection ); + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java index c7a662e233f..06971aabf49 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java @@ -14,8 +14,8 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.internal.ui.CBreakpointUpdater; -import org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation; import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry; +import org.eclipse.cdt.debug.internal.ui.CDebugModelPresentation; import org.eclipse.cdt.debug.internal.ui.ColorManager; import org.eclipse.cdt.debug.internal.ui.EvaluationContextManager; import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants; @@ -100,8 +100,8 @@ public class CDebugUIPlugin extends AbstractUIPlugin { return ColorManager.getDefault().getColor( PreferenceConverter.getColor( getDefault().getPreferenceStore(), type ) ); } - public static CDTDebugModelPresentation getDebugModelPresentation() { - return CDTDebugModelPresentation.getDefault(); + public static CDebugModelPresentation getDebugModelPresentation() { + return CDebugModelPresentation.getDefault(); } /**