diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index fc4fe31bdca..72f1562ebc3 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,10 @@ +2002-12-17 Mikhail Khodjaiants + The UI part of the prompting source locator. + * AttachSourceLocationBlock.java + * AttachSourceLocationDialog.java + * CUISourceLocator.java + * plugin.xml + 2002-12-16 Mikhail Khodjaiants New formating actions for variables, registers, and expressions * VariableFormatActionDelegate.java diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index fea5cceb618..8de03082406 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -667,14 +667,6 @@ id="org.eclipse.cdt.debug.internal.ui.editors.DebugTextHover"> - - - - "org.eclipse.cdt.debug.ui.cSourceLocator"). - */ - public static final String ID_PROMPTING_C_SOURCE_LOCATOR = CDebugUIPlugin.getUniqueIdentifier() + ".cSourceLocator"; //$NON-NLS-1$ - - /** - * The project being debugged. - */ - private IProject fProject = null; - - /** - * Underlying source locator. - */ - private CSourceLocator fSourceLocator; - - /** - * Whether the user should be prompted for source. - * Initially true, until the user checks the 'do not - * ask again' box. - */ - protected boolean fAllowedToAsk; - - - /** - * Constructor for CUISourceLocator. - */ - public CUISourceLocator() - { - fSourceLocator = new CSourceLocator(); - fAllowedToAsk = true; - } - - /** - * Constructor for CUISourceLocator. - */ - public CUISourceLocator( IProject project ) - { - fProject = project; - fSourceLocator = new CSourceLocator( project ); - fAllowedToAsk = true; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento() - */ - public String getMemento() throws CoreException - { - return fSourceLocator.getMemento(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(String) - */ - public void initializeFromMemento( String memento ) throws CoreException - { - fSourceLocator.initializeFromMemento( memento ); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(ILaunchConfiguration) - */ - public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException - { - fSourceLocator.initializeDefaults( configuration ); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(IStackFrame) - */ - public Object getSourceElement( IStackFrame stackFrame ) - { - Object res = fSourceLocator.getSourceElement( stackFrame ); - if ( res == null && fAllowedToAsk ) - { - IStackFrameInfo frameInfo = (IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class ); - if ( frameInfo != null ) - { - showDebugSourcePage( frameInfo.getFile(), stackFrame.getLaunch().getLaunchConfiguration() ); - res = fSourceLocator.getSourceElement( stackFrame ); - } - } - return res; - } - - /** - * Prompts to locate the source of the given type. - * - * @param frameInfo the frame information for which source - * could not be located - */ - private void showDebugSourcePage( final String fileName, final ILaunchConfiguration lc ) - { - Runnable prompter = new Runnable() - { - public void run() - { - SourceLookupDialog dialog = new SourceLookupDialog( CDebugUIPlugin.getActiveWorkbenchShell(), fileName, lc, CUISourceLocator.this ); - dialog.open(); - fAllowedToAsk = !dialog.isNotAskAgain(); - } - }; - CDebugUIPlugin.getStandardDisplay().syncExec( prompter ); - } - - /** - * Dialog that prompts for source lookup path. - */ - private static class SourceLookupDialog extends Dialog - { - - private CUISourceLocator fLocator; - private ILaunchConfiguration fConfiguration; - private String fFileName; - private boolean fNotAskAgain; - private Button fAskAgainCheckBox; - - public SourceLookupDialog( Shell shell, - String fileName, - ILaunchConfiguration configuration, - CUISourceLocator locator ) - { - super( shell ); - fFileName = fileName; - fNotAskAgain = false; - fAskAgainCheckBox = null; - fLocator = locator; - fConfiguration = configuration; - } - - public boolean isNotAskAgain() - { - return fNotAskAgain; - } - - protected Control createDialogArea( Composite parent ) - { - getShell().setText( "Debugger Source Lookup" ); - - Composite composite = (Composite)super.createDialogArea( parent ); - composite.setLayout( new GridLayout() ); - Label message = new Label( composite, SWT.LEFT + SWT.WRAP ); - message.setText( MessageFormat.format( "The source could not be shown as the file ''{0}'' was not found.", new String[] { fFileName } ) ); - GridData data = new GridData(); - data.widthHint = convertWidthInCharsToPixels( message, 70 ); - message.setLayoutData( data ); - fAskAgainCheckBox = new Button( composite, SWT.CHECK + SWT.WRAP ); - data = new GridData(); - data.widthHint = convertWidthInCharsToPixels( fAskAgainCheckBox, 70 ); - fAskAgainCheckBox.setLayoutData(data); - fAskAgainCheckBox.setText( "Do ¬ ask again" ); - - return composite; - } - - /** - * @see Dialog#convertWidthInCharsToPixels(FontMetrics, int) - */ - protected int convertWidthInCharsToPixels( Control control, int chars ) - { - GC gc = new GC( control ); - gc.setFont( control.getFont() ); - FontMetrics fontMetrics = gc.getFontMetrics(); - gc.dispose(); - return Dialog.convertWidthInCharsToPixels( fontMetrics, chars ); - } - - protected void okPressed() - { - try - { - if ( fAskAgainCheckBox != null ) - { - fNotAskAgain = fAskAgainCheckBox.getSelection(); - } - ILaunchConfigurationWorkingCopy wc = fConfiguration.getWorkingCopy(); - if ( !fConfiguration.contentsEqual( wc ) ) - { - fConfiguration = wc.doSave(); - fLocator.initializeDefaults( fConfiguration ); - } - } - catch( CoreException e ) - { - CDebugUIPlugin.log( e ); - } - super.okPressed(); - } - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationBlock.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationBlock.java new file mode 100644 index 00000000000..22bed4ceeb0 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationBlock.java @@ -0,0 +1,200 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.ui.sourcelookup; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.FontMetrics; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +/** + * Enter type comment. + * + * @since: Dec 12, 2002 + */ +public class AttachSourceLocationBlock +{ + private Composite fControl = null; + private Text fLocationText = null; + private Text fAssociationText = null; + private Button fAssocitedCheckButton = null; + private FontMetrics fFontMetrics; + private Shell fShell = null; + + /** + * Constructor for AttachSourceLocationBlock. + */ + public AttachSourceLocationBlock() + { + } + + public void createControl( Composite parent ) + { + fShell = parent.getShell(); + fControl = new Composite( parent, SWT.NONE ); + fControl.setLayout( new GridLayout() ); + fControl.setLayoutData( new GridData( GridData.FILL_BOTH ) ); + fControl.setFont( JFaceResources.getDialogFont() ); + initializeDialogUnits( fControl ); + + createLocationControls( fControl ); + createAssociationControls( fControl ); + } + + public void setInitialLocationPath( IPath path ) + { + if ( path != null ) + { + fLocationText.setText( path.toOSString() ); + } + } + + public void setInitialAssociationPath( IPath path ) + { + if ( path != null ) + { + fAssocitedCheckButton.setSelection( true ); + fAssociationText.setText( path.toOSString() ); + } + } + + public Control getControl() + { + return fControl; + } + + protected void createLocationControls( Composite parent ) + { + Label label = new Label( parent, SWT.NONE ); + label.setText( "Select location directory:" ); + label.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL ) ); + Composite composite = new Composite( parent, SWT.NONE ); + composite.setLayout( new GridLayout( 2, false ) ); + GridData data = new GridData( GridData.FILL_BOTH ); + data.widthHint = Dialog.convertWidthInCharsToPixels( fFontMetrics, 70 ); + composite.setLayoutData( data ); + fLocationText = new Text( composite, SWT.SINGLE | SWT.BORDER ); + fLocationText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL ) ); + Button button = createButton( composite, "&Browse..." ); + button.addSelectionListener( new SelectionAdapter() + { + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(SelectionEvent) + */ + public void widgetSelected( SelectionEvent e ) + { + selectLocation(); + } + } ); + } + + protected void selectLocation() + { + DirectoryDialog dialog = new DirectoryDialog( fShell ); + dialog.setMessage( "Select Location Directory" ); + String result = dialog.open(); + if ( result != null ) + { + fLocationText.setText( result ); + } + } + + protected void createAssociationControls( Composite parent ) + { + Composite composite = new Composite( parent, SWT.NONE ); + composite.setLayout( new GridLayout() ); + GridData data = new GridData( GridData.FILL_BOTH ); + composite.setLayoutData( data ); + fAssocitedCheckButton = new Button( composite, SWT.CHECK ); + fAssocitedCheckButton.setText( "&Associate with" ); + fAssociationText = new Text( composite, SWT.SINGLE | SWT.BORDER ); + fAssociationText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); + fAssocitedCheckButton.addSelectionListener( new SelectionAdapter() + { + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(SelectionEvent) + */ + public void widgetSelected(SelectionEvent e) + { + associationSelectionChanged(); + } + + } ); + } + + protected void associationSelectionChanged() + { + boolean checked = fAssocitedCheckButton.getSelection(); + fAssociationText.setEnabled( checked ); + if ( !checked ) + fAssociationText.setText( "" ); + } + + protected Button createButton( Composite parent, String label ) + { + Button button = new Button( parent, SWT.PUSH ); + button.setText( label ); + GridData data = new GridData( GridData.END ); + data.heightHint = convertVerticalDLUsToPixels( IDialogConstants.BUTTON_HEIGHT ); + int widthHint = convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH ); + data.widthHint = Math.max( widthHint, button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x ); + button.setLayoutData( data ); + button.setFont( parent.getFont() ); + + return button; + } + + protected int convertVerticalDLUsToPixels( int dlus ) + { + if ( fFontMetrics == null ) + return 0; + return Dialog.convertVerticalDLUsToPixels( fFontMetrics, dlus ); + } + + protected int convertHorizontalDLUsToPixels( int dlus ) + { + if ( fFontMetrics == null ) + return 0; + return Dialog.convertHorizontalDLUsToPixels( fFontMetrics, dlus ); + } + + protected void initializeDialogUnits( Control control ) + { + // Compute and store a font metric + GC gc = new GC( control ); + gc.setFont( control.getFont() ); + fFontMetrics = gc.getFontMetrics(); + gc.dispose(); + } + + public String getLocationPath() + { + return fLocationText.getText().trim(); + } + + public String getAssociationPath() + { + if ( fAssocitedCheckButton.getSelection() ) + { + return fAssociationText.getText().trim(); + } + return ""; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationDialog.java new file mode 100644 index 00000000000..d31732476ad --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/AttachSourceLocationDialog.java @@ -0,0 +1,130 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.ui.sourcelookup; + +import java.text.MessageFormat; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +/** + * Enter type comment. + * + * @since: Dec 12, 2002 + */ +public class AttachSourceLocationDialog extends Dialog +{ + private IPath fLocationPath = null; + private IPath fAssociationPath = null; + private AttachSourceLocationBlock fAttachBlock; + + /** + * Constructor for AttachSourceLocationDialog. + * @param parentShell + */ + public AttachSourceLocationDialog( Shell parentShell ) + { + super( parentShell ); + fAttachBlock = new AttachSourceLocationBlock(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite) + */ + protected Control createDialogArea( Composite parent ) + { + Composite composite = (Composite)super.createDialogArea( parent ); + getShell().setText( "Attach Source Location" ); + fAttachBlock.createControl( composite ); + fAttachBlock.setInitialAssociationPath( fAssociationPath ); + + return composite; + } + + public void setInitialPath( IPath path ) + { + fAssociationPath = path; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() + { + String locationString = fAttachBlock.getLocationPath(); + if ( locationString.length() == 0 ) + { + MessageDialog.openError( getShell(), getShell().getText(), "Location directory is not selected" ); + return; + } + if ( !isLocationPathValid( locationString ) ) + { + MessageDialog.openError( getShell(), getShell().getText(), MessageFormat.format( "Invalid path: ''{0}''", new String[] { locationString } ) ); + return; + } + String associationString = fAttachBlock.getAssociationPath(); + if ( !isAssociationPathValid( associationString ) ) + { + MessageDialog.openError( getShell(), getShell().getText(), MessageFormat.format( "Invalid path: ''{0}''", new String[] { associationString } ) ); + return; + } + fLocationPath = getLocation0(); + fAssociationPath = getAssociation0(); + super.okPressed(); + } + + public boolean isLocationPathValid( String pathString ) + { + if ( Path.EMPTY.isValidPath( pathString ) ) + { + Path path = new Path( pathString ); + return path.toFile().exists(); + } + return false; + } + + public boolean isAssociationPathValid( String pathString ) + { + if ( pathString.length() > 0 ) + { + return Path.EMPTY.isValidPath( pathString ); + } + return true; + } + + public IPath getLocation() + { + return fLocationPath; + } + + private IPath getLocation0() + { + if ( Path.EMPTY.isValidPath( fAttachBlock.getLocationPath() ) ) + { + return new Path( fAttachBlock.getLocationPath() ); + } + return null; + } + + public IPath getAssociation() + { + return fAssociationPath; + } + + private IPath getAssociation0() + { + if ( Path.EMPTY.isValidPath( fAttachBlock.getAssociationPath() ) ) + { + return new Path( fAttachBlock.getAssociationPath() ); + } + return null; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java new file mode 100644 index 00000000000..6d4012e7a64 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java @@ -0,0 +1,274 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.ui.sourcelookup; + +import java.text.MessageFormat; + +import org.eclipse.cdt.debug.core.model.IStackFrameInfo; +import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; +import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode; +import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation; +import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator; +import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Path; +import org.eclipse.debug.core.model.IStackFrame; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.FontMetrics; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.Shell; + +/** + * + * A source locator that prompts the user to find source when source cannot + * be found on the current source lookup path. + * + * @since Sep 24, 2002 + */ +public class CUISourceLocator implements IAdaptable +{ + /** + * Dialog that prompts for source lookup path. + */ + private static class SourceLookupDialog extends Dialog + { + public static final int ATTACH_ID = 1000; + public static final int ATTACH = 1000; + + private String fFileName; + private boolean fNotAskAgain; + private Button fAskAgainCheckBox; + + public SourceLookupDialog( Shell shell, + String fileName ) + { + super( shell ); + fFileName = fileName; + fNotAskAgain = false; + fAskAgainCheckBox = null; + } + + public boolean isNotAskAgain() + { + return fNotAskAgain; + } + + protected Control createDialogArea( Composite parent ) + { + getShell().setText( "Debugger Source Lookup" ); + + Composite composite = (Composite)super.createDialogArea( parent ); + composite.setLayout( new GridLayout() ); + Composite group = new Composite( composite, SWT.NONE ); + group.setLayout( new GridLayout() ); + createMessageControls( group ); + createControls( group ); + + return composite; + } + + protected void createMessageControls( Composite parent ) + { + Label message = new Label( parent, SWT.LEFT + SWT.WRAP ); + message.setText( MessageFormat.format( "The source could not be shown as the file ''{0}'' was not found.", new String[] { fFileName } ) ); + GridData data = new GridData(); + data.widthHint = convertWidthInCharsToPixels( message, 70 ); + message.setLayoutData( data ); + } + + protected void createControls( Composite parent ) + { + Composite composite = new Composite( parent, SWT.NONE ); + Layout layout = new GridLayout(); + composite.setLayout( layout ); + GridData data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + composite.setLayoutData( data ); + fAskAgainCheckBox = new Button( composite, SWT.CHECK + SWT.WRAP ); + data = new GridData(); + data.horizontalAlignment = GridData.FILL; + fAskAgainCheckBox.setLayoutData( data ); + data.grabExcessHorizontalSpace = true; + fAskAgainCheckBox.setText( "Do ¬ ask again" ); + fAskAgainCheckBox.addSelectionListener( new SelectionAdapter() + { + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(SelectionEvent) + */ + public void widgetSelected( SelectionEvent e ) + { + askAgainSelected(); + } + } ); + } + + protected void askAgainSelected() + { + getButton( ATTACH_ID ).setEnabled( !fAskAgainCheckBox.getSelection() ); + } + + /** + * @see Dialog#convertWidthInCharsToPixels(FontMetrics, int) + */ + protected int convertWidthInCharsToPixels( Control control, int chars ) + { + GC gc = new GC( control ); + gc.setFont( control.getFont() ); + FontMetrics fontMetrics = gc.getFontMetrics(); + gc.dispose(); + return Dialog.convertWidthInCharsToPixels( fontMetrics, chars ); + } + + protected void okPressed() + { + if ( fAskAgainCheckBox != null ) + { + fNotAskAgain = fAskAgainCheckBox.getSelection(); + } + super.okPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(Composite) + */ + protected void createButtonsForButtonBar( Composite parent ) + { + super.createButtonsForButtonBar( parent ); + Button button = createButton( parent, ATTACH_ID, "&Attach ...", false ); + button.setToolTipText( "Attach New Source Location" ); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) + */ + protected void buttonPressed( int buttonId ) + { + super.buttonPressed( buttonId ); + if ( buttonId == ATTACH_ID ) + attachPressed(); + } + + protected void attachPressed() + { + setReturnCode( ATTACH ); + close(); + } + } + + /** + * The project being debugged. + */ + private IProject fProject = null; + + /** + * Underlying source locator. + */ + private CSourceManager fSourceLocator; + + /** + * Whether the user should be prompted for source. + * Initially true, until the user checks the 'do not + * ask again' box. + */ + protected boolean fAllowedToAsk; + + protected boolean fNewLocationAttached; + + /** + * Constructor for CUISourceLocator. + */ + public CUISourceLocator( IProject project ) + { + fProject = project; + fSourceLocator = new CSourceManager( new CSourceLocator( project ) ); + fAllowedToAsk = true; + fNewLocationAttached = false; + } + + public Object getSourceElement( IStackFrame stackFrame ) + { + Object res = fSourceLocator.getSourceElement( stackFrame ); + if ( res == null && fAllowedToAsk ) + { + IStackFrameInfo frameInfo = (IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class ); + if ( frameInfo != null ) + { + showDebugSourcePage( frameInfo.getFile() ); + if ( fNewLocationAttached ) + { + res = fSourceLocator.getSourceElement( stackFrame ); + } + } + } + return res; + } + + /** + * Prompts to locate the source of the given type. + * + * @param frameInfo the frame information for which source + * could not be located + */ + private void showDebugSourcePage( final String fileName ) + { + Runnable prompter = new Runnable() + { + public void run() + { + SourceLookupDialog dialog = new SourceLookupDialog( CDebugUIPlugin.getActiveWorkbenchShell(), fileName ); + if ( dialog.open() == SourceLookupDialog.ATTACH ) + { + attachSourceLocation( fileName ); + } + fAllowedToAsk = !dialog.isNotAskAgain(); + } + }; + CDebugUIPlugin.getStandardDisplay().syncExec( prompter ); + } + + protected void attachSourceLocation( String fileName ) + { + AttachSourceLocationDialog dialog = new AttachSourceLocationDialog( CDebugUIPlugin.getActiveWorkbenchShell() ); + Path path = new Path( fileName ); + dialog.setInitialPath( path.removeLastSegments( 1 ) ); + if ( dialog.open() == Dialog.OK ) + { + if ( dialog.getLocation() != null ) + { + fSourceLocator.addSourceLocation( new CDirectorySourceLocation( dialog.getLocation(), dialog.getAssociation() ) ); + fNewLocationAttached = true; + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class) + */ + public Object getAdapter( Class adapter ) + { + if ( fSourceLocator != null ) + { + if ( adapter.equals( ICSourceLocator.class ) ) + return fSourceLocator; + if ( adapter.equals( ISourceMode.class ) ) + return fSourceLocator; + } + return null; + } +}