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

fix source locator

This commit is contained in:
David Inglis 2003-02-20 22:03:23 +00:00
parent d06efcf027
commit c0bb4d9b23
4 changed files with 52 additions and 47 deletions

View file

@ -1,3 +1,8 @@
2003-02-20 Mikhail Khodjaiants
The generation of launch configuration shouldn't fail if project is not set or project name is empty.
* DefaultSourceLocator.java
* CSourceLookupTab.java
2003-02-18 Mikhail Khodjaiants 2003-02-18 Mikhail Khodjaiants
New 'Source Lookup' tab. New 'Source Lookup' tab.
* plugin.xml * plugin.xml

View file

@ -178,7 +178,7 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
private IProject getProject( ILaunchConfiguration configuration ) throws CoreException private IProject getProject( ILaunchConfiguration configuration ) throws CoreException
{ {
String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null ); String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null );
if ( projectName != null ) if ( !isEmpty( projectName ) )
{ {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName ); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
if ( project.exists() ) if ( project.exists() )

View file

@ -106,10 +106,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
String configPlatform = getPlatform(config); String configPlatform = getPlatform(config);
String programCPU = "native"; String programCPU = "native";
ICElement ce = getContext(config, configPlatform); ICElement ce = getContext(config, configPlatform);
try { if (ce instanceof IBinary) {
IBinary bin = (IBinary) ce; IBinary bin = (IBinary) ce;
programCPU = bin.getCPU(); programCPU = bin.getCPU();
} catch (Exception e) {
} }
fDCombo.removeAll(); fDCombo.removeAll();
debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations(); debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations();
@ -246,10 +245,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
String projectPlatform = getPlatform(config); String projectPlatform = getPlatform(config);
String projectCPU = "native"; String projectCPU = "native";
if (ce != null) { if (ce != null) {
try { if (ce instanceof IBinary) {
IBinary bin = (IBinary) ce; IBinary bin = (IBinary) ce;
projectCPU = bin.getCPU(); projectCPU = bin.getCPU();
} catch (Exception e) {
} }
} }
ICDebugConfiguration debugConfig = getDebugConfig(); ICDebugConfiguration debugConfig = getDebugConfig();

View file

@ -7,7 +7,6 @@ package org.eclipse.cdt.launch.ui;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.sourcelookup.SourceLookupBlock; import org.eclipse.cdt.debug.ui.sourcelookup.SourceLookupBlock;
import org.eclipse.cdt.launch.sourcelookup.DefaultSourceLocator; import org.eclipse.cdt.launch.sourcelookup.DefaultSourceLocator;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -15,6 +14,8 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
/** /**
@ -31,10 +32,12 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
*/ */
public void createControl( Composite parent ) public void createControl( Composite parent )
{ {
Composite control = new Composite( parent, SWT.NONE );
control.setLayout( new GridLayout() );
fBlock = new SourceLookupBlock(); fBlock = new SourceLookupBlock();
fBlock.createControl( parent ); fBlock.createControl( control );
fBlock.setLaunchConfigurationDialog( getLaunchConfigurationDialog() ); fBlock.setLaunchConfigurationDialog( getLaunchConfigurationDialog() );
setControl( fBlock.getControl() ); setControl( control );
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -43,22 +46,16 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) public void setDefaults( ILaunchConfigurationWorkingCopy configuration )
{ {
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR ); configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
DefaultSourceLocator locator = new DefaultSourceLocator();
try
{
locator.initializeDefaults( configuration );
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
}
catch( CoreException e )
{
CDebugUIPlugin.log( e.getStatus() );
}
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
*/ */
public void initializeFrom( ILaunchConfiguration configuration ) public void initializeFrom( ILaunchConfiguration configuration )
{
IProject project = getProject( configuration );
fBlock.setProject( getProject( configuration ) );
if ( project != null )
{ {
try try
{ {
@ -77,18 +74,23 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
} }
ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class ); ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
if ( clocator != null ) if ( clocator != null )
fBlock.initialize( clocator.getSourceLocations() ); fBlock.initialize( clocator );
} }
} }
catch( CoreException e ) catch( CoreException e )
{ {
} }
} }
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/ */
public void performApply( ILaunchConfigurationWorkingCopy configuration ) public void performApply( ILaunchConfigurationWorkingCopy configuration )
{
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
IProject project = getProject( configuration );
if ( project != null )
{ {
DefaultSourceLocator locator = new DefaultSourceLocator(); DefaultSourceLocator locator = new DefaultSourceLocator();
try try
@ -97,20 +99,20 @@ public class CSourceLookupTab extends CLaunchConfigurationTab
ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class ); ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
if ( clocator != null ) if ( clocator != null )
clocator.setSourceLocations( fBlock.getSourceLocations() ); clocator.setSourceLocations( fBlock.getSourceLocations() );
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() ); configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
} }
catch( CoreException e ) catch( CoreException e )
{ {
} }
} }
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/ */
public String getName() public String getName()
{ {
return "Source Lookup"; return "Source";
} }
private IProject getProject( ILaunchConfiguration configuration ) private IProject getProject( ILaunchConfiguration configuration )