1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Moved 'DefaultSourceLocator' from the 'org.eclipse.cdt.launch' plugin and merge it with 'CUISourceLocator'.

Added dependency to 'org.apache.xerces'.
Moved the 'org.eclipse.debug.core.sourceLocators' extension from the launcher.
Changed the initialization of 'SourceLookupBlock'.
This commit is contained in:
Mikhail Khodjaiants 2003-10-27 20:18:25 +00:00
parent 330c815c5f
commit 5df215664c
9 changed files with 385 additions and 77 deletions

View file

@ -8,6 +8,7 @@
<classpathentry kind="src" path="/org.eclipse.cdt.debug.core"/>
<classpathentry kind="src" path="/org.eclipse.cdt.ui"/>
<classpathentry kind="src" path="/org.eclipse.cdt.core"/>
<classpathentry kind="src" path="/org.apache.xerces"/>
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>

View file

@ -3,6 +3,7 @@
<name>org.eclipse.cdt.debug.ui</name>
<comment></comment>
<projects>
<project>org.apache.xerces</project>
<project>org.eclipse.cdt.core</project>
<project>org.eclipse.cdt.debug.core</project>
<project>org.eclipse.cdt.ui</project>

View file

@ -1,3 +1,25 @@
2003-10-27 Mikhail Khodjaiants
Changed the initialization of 'SourceLookupBlock'.
* SourceLookupBlock.java
* SourcePropertyPage.java
2003-10-27 Mikhail Khodjaiants
Moved the 'org.eclipse.debug.core.sourceLocators' extension from the launcher.
* plugin.xml
* plugin.properties
2003-10-27 Mikhail Khodjaiants
Added dependency to 'org.apache.xerces'.
* plugin.xml
* .classpath
* .project
2003-10-27 Mikhail Khodjaiants
Moved 'DefaultSourceLocator' from the 'org.eclipse.cdt.launch' plugin and merge it with 'CUISourceLocator'.
* CUISourceLocator.java: removed
* DefaultSourceLocator.java: moved from the launcher.
* CDebugUIPlugin.java: added the 'createSourceLocator' method.
2003-10-27 Mikhail Khodjaiants
Renamed 'SourceLocationFactory' to 'SourceLookupFactory'.
* AddDirectorySourceLocationBlock.java

View file

@ -80,3 +80,5 @@ EnableVariablesAction.tooltip=Enable Selected Variables
DisableVariablesAction.label=Disable
DisableVariablesAction.tooltip=Disable Selected Variables
DefaultSourceLocator.name=Default C/C++ Source Locator

View file

@ -19,6 +19,7 @@
<import plugin="org.eclipse.cdt.debug.core"/>
<import plugin="org.eclipse.cdt.ui"/>
<import plugin="org.eclipse.cdt.core"/>
<import plugin="org.apache.xerces"/>
</requires>
@ -1243,5 +1244,13 @@
id="org.eclipse.cdt.debug.ui.editor.CDebugEditor">
</editor>
</extension>
<extension
point="org.eclipse.debug.core.sourceLocators">
<sourceLocator
class="org.eclipse.cdt.debug.ui.sourcelookup.DefaultSourceLocator"
name="%DefaultSourceLocator.name"
id="org.eclipse.cdt.debug.ui.DefaultSourceLocator">
</sourceLocator>
</extension>
</plugin>

View file

@ -19,6 +19,7 @@ import org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage;
import org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage;
import org.eclipse.cdt.debug.internal.ui.preferences.RegistersViewPreferencePage;
import org.eclipse.cdt.debug.internal.ui.preferences.SharedLibrariesViewPreferencePage;
import org.eclipse.cdt.debug.ui.sourcelookup.DefaultSourceLocator;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
@ -34,6 +35,7 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IDebugEventSetListener;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IPersistableSourceLocator;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.ui.IDebugUIConstants;
@ -508,4 +510,22 @@ public class CDebugUIPlugin extends AbstractUIPlugin
display.asyncExec( runnable );
}
}
public static IPersistableSourceLocator createDefaultSourceLocator()
{
return new DefaultSourceLocator();
}
public static String getDefaultSourceLocatorID()
{
return DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR;
}
/*
* to support old launch configurations
*/
public static String getDefaultSourceLocatorOldID()
{
return DefaultSourceLocator.ID_OLD_DEFAULT_SOURCE_LOCATOR;
}
}

View file

@ -3,17 +3,27 @@
* All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.ui.sourcelookup;
import java.io.IOException;
import java.io.StringReader;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.xerces.dom.DocumentImpl;
import org.eclipse.cdt.core.resources.FileStorage;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
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.CSourceLocator;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceManager;
import org.eclipse.cdt.debug.core.sourcelookup.SourceLookupFactory;
import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry;
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
import org.eclipse.cdt.debug.internal.ui.dialogfields.SelectionButtonDialogField;
@ -24,9 +34,11 @@ import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IPersistableSourceLocator;
@ -39,15 +51,17 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ListDialog;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* Enter type comment.
*
* 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
* @since Oct 24, 2003
*/
public class CUISourceLocator implements IAdaptable
public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptable
{
public class SourceSelectionDialog extends ListDialog
{
@ -105,6 +119,18 @@ public class CUISourceLocator implements IAdaptable
}
}
/**
* Identifier for the 'Default C/C++ Source Locator' extension
* (value <code>"org.eclipse.cdt.debug.ui.DefaultSourceLocator"</code>).
*/
public static final String ID_DEFAULT_SOURCE_LOCATOR = CDebugUIPlugin.getUniqueIdentifier() + ".DefaultSourceLocator"; //$NON-NLS-1$
// to support old configurations
public static final String ID_OLD_DEFAULT_SOURCE_LOCATOR = "org.eclipse.cdt.launch" + ".DefaultSourceLocator"; //$NON-NLS-1$
private static final String ELEMENT_NAME = "PromptingSourceLocator";
private static final String ATTR_PROJECT = "project";
private static final String ATTR_MEMENTO = "memento";
/**
* The project being debugged.
*/
@ -113,20 +139,147 @@ public class CUISourceLocator implements IAdaptable
/**
* Underlying source locator.
*/
private CSourceManager fSourceLocator;
private ICSourceLocator fSourceLocator;
private HashMap fFramesToSource = null;
private HashMap fNamesToSource = null;
/**
* Constructor for CUISourceLocator.
*/
public CUISourceLocator( IProject project )
public DefaultSourceLocator()
{
fProject = project;
fSourceLocator = new CSourceManager( new CSourceLocator( project ) );
super();
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
*/
public String getMemento() throws CoreException
{
if ( fSourceLocator != null )
{
Document doc = new DocumentImpl();
Element node = doc.createElement( ELEMENT_NAME );
doc.appendChild( node );
node.setAttribute( ATTR_PROJECT, fSourceLocator.getProject().getName() );
IPersistableSourceLocator psl = getPersistableSourceLocator();
if ( psl != null )
{
node.setAttribute( ATTR_MEMENTO, psl.getMemento() );
}
try
{
return CDebugUtils.serializeDocument( doc, " " );
}
catch( IOException e )
{
abort( "Unable to create memento for C/C++ source locator.", e );
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(java.lang.String)
*/
public void initializeFromMemento( String memento ) throws CoreException
{
Exception ex = null;
try
{
Element root = null;
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
StringReader reader = new StringReader( memento );
InputSource source = new InputSource( reader );
root = parser.parse( source ).getDocumentElement();
if ( !root.getNodeName().equalsIgnoreCase( ELEMENT_NAME ) )
{
abort( "Unable to restore prompting source locator - invalid format.", null );
}
String projectName = root.getAttribute( ATTR_PROJECT );
String data = root.getAttribute( ATTR_MEMENTO );
if ( isEmpty( projectName ) )
{
abort( "Unable to restore prompting source locator - invalid format.", null );
}
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
if ( project == null || !project.exists() || !project.isOpen() )
{
abort( MessageFormat.format( "Unable to restore prompting source locator - project {0} not found.", new String[] { projectName } ), null );
}
ICSourceLocator locator = getCSourceLocator();
if ( locator == null )
{
fSourceLocator = SourceLookupFactory.createSourceLocator( project );
}
else if ( locator.getProject() != null && !project.equals( locator.getProject() ) )
{
return;
}
IPersistableSourceLocator psl = getPersistableSourceLocator();
if ( psl != null )
{
psl.initializeFromMemento( data );
}
else
{
abort( "Unable to restore C/C++ source locator - invalid format.", null );
}
return;
}
catch( ParserConfigurationException e )
{
ex = e;
}
catch( SAXException e )
{
ex = e;
}
catch( IOException e )
{
ex = e;
}
abort( "Exception occurred initializing source locator.", ex );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(org.eclipse.debug.core.ILaunchConfiguration)
*/
public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException
{
fSourceLocator = SourceLookupFactory.createSourceLocator( getProject( configuration ) );
String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
if ( !isEmpty( memento ) )
initializeFromMemento( memento );
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter( Class adapter )
{
if ( fSourceLocator instanceof IAdaptable )
{
if ( adapter.equals( ICSourceLocator.class ) )
{
return ((IAdaptable)fSourceLocator).getAdapter( adapter );
}
if ( adapter.equals( IResourceChangeListener.class ) )
{
return ((IAdaptable)fSourceLocator).getAdapter( adapter );
}
if ( adapter.equals( ISourceMode.class ) )
{
return ((IAdaptable)fSourceLocator).getAdapter( adapter );
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(org.eclipse.debug.core.model.IStackFrame)
*/
public Object getSourceElement( IStackFrame stackFrame )
{
Object res = cacheLookup( stackFrame );
@ -164,23 +317,6 @@ public class CUISourceLocator implements IAdaptable
return res;
}
/* (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( IResourceChangeListener.class ) && fSourceLocator instanceof IAdaptable )
return ((IAdaptable)fSourceLocator).getAdapter( IResourceChangeListener.class );
if ( adapter.equals( ISourceMode.class ) )
return fSourceLocator;
}
return null;
}
public IProject getProject()
{
return fProject;
@ -255,4 +391,44 @@ public class CUISourceLocator implements IAdaptable
}
return null;
}
private ICSourceLocator getCSourceLocator()
{
return fSourceLocator;
}
private IPersistableSourceLocator getPersistableSourceLocator()
{
ICSourceLocator sl = getCSourceLocator();
return ( sl instanceof IPersistableSourceLocator ) ? (IPersistableSourceLocator)sl : null;
}
/**
* Throws an internal error exception
*/
private void abort( String message, Throwable e ) throws CoreException
{
IStatus s = new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), 0, message, e );
throw new CoreException( s );
}
private boolean isEmpty( String string )
{
return string == null || string.length() == 0;
}
private IProject getProject( ILaunchConfiguration configuration ) throws CoreException
{
String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null );
if ( !isEmpty( projectName ) )
{
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
if ( project.exists() )
{
return project;
}
}
abort( MessageFormat.format( "Project \"{0}\" does not exist.", new String[] { projectName } ), null );
return null;
}
}

View file

@ -13,11 +13,12 @@ import java.util.Observer;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.ICDebugConstants;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
import org.eclipse.cdt.debug.core.sourcelookup.SourceLocationFactory;
import org.eclipse.cdt.debug.core.sourcelookup.SourceLookupFactory;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator;
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
import org.eclipse.cdt.debug.internal.ui.dialogfields.CheckedListDialogField;
@ -28,7 +29,14 @@ import org.eclipse.cdt.debug.internal.ui.dialogfields.LayoutUtil;
import org.eclipse.cdt.debug.internal.ui.dialogfields.SelectionButtonDialogField;
import org.eclipse.cdt.debug.internal.ui.dialogfields.Separator;
import org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IPersistableSourceLocator;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
@ -116,28 +124,83 @@ public class SourceLookupBlock implements Observer
return fControl;
}
public void initialize( ICSourceLocator locator )
public void initialize( ILaunchConfiguration configuration )
{
if ( locator != null )
IProject project = getProjectFromLaunchConfiguration( configuration );
if ( project != null )
{
IProject oldProject = getProject();
setProject( project );
if ( project.equals( oldProject ) )
{
try
{
String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" );
if ( isEmpty( id ) ||
CDebugUIPlugin.getDefaultSourceLocatorID().equals( id ) ||
CDebugUIPlugin.getDefaultSourceLocatorOldID().equals( id ) )
{
String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
if ( !isEmpty( memento ) )
initializeFromMemento( memento );
else
initializeDefaults();
}
}
catch( CoreException e )
{
initializeDefaults();
}
}
else
initializeDefaults();
}
else
{
initializeGeneratedLocations( null, new ICSourceLocation[0] );
resetAdditionalLocations( CDebugCorePlugin.getDefault().getCommonSourceLocations() );
fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) );
}
}
private void initializeFromMemento( String memento ) throws CoreException
{
IPersistableSourceLocator locator = CDebugUIPlugin.createDefaultSourceLocator();
locator.initializeFromMemento( memento );
if ( locator instanceof IAdaptable )
{
ICSourceLocator clocator = (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class );
if ( clocator != null )
initializeFromLocator( clocator );
}
}
private void initializeDefaults()
{
initializeGeneratedLocations( getProject(), new ICSourceLocation[] { SourceLookupFactory.createProjectSourceLocation( getProject() ) } );
resetAdditionalLocations( CDebugCorePlugin.getDefault().getCommonSourceLocations() );
fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) );
}
private void initializeFromLocator( ICSourceLocator locator )
{
ICSourceLocation[] locations = locator.getSourceLocations();
initializeGeneratedLocations( locator.getProject(), locations );
resetAdditionalLocations( locations );
fSearchForDuplicateFiles.setSelection( locator.searchForDuplicateFiles() );
}
}
private void initializeGeneratedLocations( IProject project, ICSourceLocation[] locations )
{
fGeneratedSourceListField.removeAllElements();
if ( project == null && project.exists() && project.isOpen() )
if ( project == null || !project.exists() || !project.isOpen() )
return;
List list = CDebugUtils.getReferencedProjects( project );
IProject[] refs = (IProject[])list.toArray( new IProject[list.size()] );
ICSourceLocation loc = getLocationForProject( project, locations );
boolean checked = ( loc != null && ((IProjectSourceLocation)loc).isGeneric() );
if ( loc == null )
loc = SourceLocationFactory.createProjectSourceLocation( project, true );
loc = SourceLookupFactory.createProjectSourceLocation( project, true );
fGeneratedSourceListField.addElement( loc );
fGeneratedSourceListField.setChecked( loc, checked );
@ -146,7 +209,7 @@ public class SourceLookupBlock implements Observer
loc = getLocationForProject( refs[i], locations );
checked = ( loc != null );
if ( loc == null )
loc = SourceLocationFactory.createProjectSourceLocation( refs[i], true );
loc = SourceLookupFactory.createProjectSourceLocation( refs[i], true );
fGeneratedSourceListField.addElement( loc );
fGeneratedSourceListField.setChecked( loc, checked );
}
@ -173,6 +236,28 @@ public class SourceLookupBlock implements Observer
}
}
public void performApply( ILaunchConfigurationWorkingCopy configuration )
{
IPersistableSourceLocator locator = CDebugUIPlugin.createDefaultSourceLocator();
try
{
locator.initializeDefaults( configuration );
if ( locator instanceof IAdaptable )
{
ICSourceLocator clocator = (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class );
if ( clocator != null )
{
clocator.setSourceLocations( getSourceLocations() );
clocator.setSearchForDuplicateFiles( searchForDuplicateFiles() );
}
}
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
}
catch( CoreException e )
{
}
}
protected void doCheckStateChanged()
{
fIsDirty = true;
@ -286,7 +371,7 @@ public class SourceLookupBlock implements Observer
return fProject;
}
public void setProject( IProject project )
private void setProject( IProject project )
{
fProject = project;
}
@ -401,6 +486,11 @@ public class SourceLookupBlock implements Observer
updateLaunchConfigurationDialog();
}
private boolean isEmpty( String string )
{
return string == null || string.length() == 0;
}
public void dispose()
{
if ( getAddedSourceListField() != null )
@ -409,4 +499,22 @@ public class SourceLookupBlock implements Observer
getAddedSourceListField().dispose();
}
}
private IProject getProjectFromLaunchConfiguration( ILaunchConfiguration configuration )
{
try
{
String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "" );
if ( !isEmpty( projectName ) )
{
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
if ( project != null && project.exists() && project.isOpen() )
return project;
}
}
catch( CoreException e )
{
}
return null;
}
}

View file

@ -5,12 +5,9 @@
*/
package org.eclipse.cdt.debug.ui.sourcelookup;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
@ -68,8 +65,7 @@ public class SourcePropertyPage extends PropertyPage
protected Control createActiveContents( Composite parent )
{
fBlock.setProject( getProject() );
fBlock.initialize( getSourceLocator() );
fBlock.initialize( getLaunchConfiguration() );
fBlock.createControl( parent );
return fBlock.getControl();
}
@ -84,19 +80,6 @@ public class SourcePropertyPage extends PropertyPage
return null;
}
private ICSourceLocator getSourceLocator()
{
ICDebugTarget target = getDebugTarget();
if ( target != null )
{
if ( target.getLaunch().getSourceLocator() instanceof IAdaptable )
{
return (ICSourceLocator)((IAdaptable)target.getLaunch().getSourceLocator()).getAdapter( ICSourceLocator.class );
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
@ -153,24 +136,10 @@ public class SourcePropertyPage extends PropertyPage
}
}
private IProject getProject()
private ILaunchConfiguration getLaunchConfiguration()
{
IProject project = null;
ICDebugTarget target = getDebugTarget();
if ( target != null )
{
ILaunchConfiguration configuration = target.getLaunch().getLaunchConfiguration();
try
{
String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "" );
if ( projectName != null && projectName.length() > 0 )
project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
}
catch( CoreException e )
{
}
}
return project;
return ( target != null ) ? target.getLaunch().getLaunchConfiguration() : null;
}
/* (non-Javadoc)